diff --git a/Jenkinsfile-Agent-Test-3 b/Jenkinsfile-Agent-Test-3 index e085418ba..85671c67d 100755 --- a/Jenkinsfile-Agent-Test-3 +++ b/Jenkinsfile-Agent-Test-3 @@ -56,8 +56,7 @@ pipeline { sh './mvnw -f test/plugin/pom.xml clean package -DskipTests -Dbuild_id=wl3_${BUILD_ID} docker:build' } } - - stage('Test Cases Report (132)') { + stage('Test Cases Report (137)') { steps { echo "reserve." } @@ -81,6 +80,11 @@ pipeline { sh 'bash test/plugin/run.sh --build_id=wl3_${BUILD_ID} sofarpc-scenario' } } + stage('mongodb 3.0-3.5.0 (5)') { + steps { + sh 'bash test/plugin/run.sh --build_id=wl3_${BUILD_ID} mongodb-3.x-scenario' + } + } stage('elasticsearch 5.x (3)') { steps { sh 'bash test/plugin/run.sh --build_id=wl3_${BUILD_ID} elasticsearch-5.x-scenario' diff --git a/docs/en/setup/service-agent/java-agent/Supported-list.md b/docs/en/setup/service-agent/java-agent/Supported-list.md index 8b73d330d..1dc9da5fd 100644 --- a/docs/en/setup/service-agent/java-agent/Supported-list.md +++ b/docs/en/setup/service-agent/java-agent/Supported-list.md @@ -50,7 +50,7 @@ * [Jedis](https://github.com/xetorthio/jedis) 2.x * [Redisson](https://github.com/redisson/redisson) Easy Java Redis client 3.5.2+ * [Lettuce](https://github.com/lettuce-io/lettuce-core) 5.x (Optional²) - * [MongoDB Java Driver](https://github.com/mongodb/mongo-java-driver) 2.13-2.14,3.3+ + * [MongoDB Java Driver](https://github.com/mongodb/mongo-java-driver) 2.13-2.14,3.4.0-3.5.0 * Memcached Client * [Spymemcached](https://github.com/couchbase/spymemcached) 2.x * [Xmemcached](https://github.com/killme2008/xmemcached) 2.x diff --git a/test/plugin/scenarios/mongodb-3.x-scenario/bin/startup.sh b/test/plugin/scenarios/mongodb-3.x-scenario/bin/startup.sh new file mode 100644 index 000000000..b236d2d77 --- /dev/null +++ b/test/plugin/scenarios/mongodb-3.x-scenario/bin/startup.sh @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#!/bin/sh + +home="$(cd "$(dirname $0)"; pwd)" + +java -jar ${agent_opts} ${home}/../libs/mongodb-3.x-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/mongodb-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/mongodb-3.x-scenario/config/expectedData.yaml new file mode 100644 index 000000000..8081780b9 --- /dev/null +++ b/test/plugin/scenarios/mongodb-3.x-scenario/config/expectedData.yaml @@ -0,0 +1,153 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +registryItems: + applications: + - {mongodb-3.x-scenario: nq 0} + instances: + - {mongodb-3.x-scenario: 1} + operationNames: + - mongodb-3.x-scenario: [/mongodb-case/case/mongodb, MongoDB/DropDatabaseOperation, MongoDB/FindOperation, + MongoDB/CreateCollectionOperation, MongoDB/MixedBulkWriteOperation] + heartbeat: [] + +segmentItems: +- applicationCode: mongodb-3.x-scenario + segmentSize: ge 2 + segments: + - segmentId: not null + spans: + - operationName: MongoDB/CreateCollectionOperation + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Database + startTime: nq 0 + endTime: nq 0 + componentId: 42 + componentName: '' + isError: false + spanType: Exit + peer: mongodb-server:27017 + peerId: 0 + tags: + - {key: db.type, value: MongoDB} + - operationName: MongoDB/MixedBulkWriteOperation + operationId: 0 + parentSpanId: 0 + spanId: 2 + spanLayer: Database + startTime: nq 0 + endTime: nq 0 + componentId: 42 + componentName: '' + isError: false + spanType: Exit + peer: mongodb-server:27017 + peerId: 0 + tags: + - {key: db.type, value: MongoDB} + - operationName: MongoDB/FindOperation + operationId: 0 + parentSpanId: 0 + spanId: 3 + spanLayer: Database + startTime: nq 0 + endTime: nq 0 + componentId: 42 + componentName: '' + isError: false + spanType: Exit + peer: mongodb-server:27017 + peerId: 0 + tags: + - {key: db.type, value: MongoDB} + - operationName: MongoDB/MixedBulkWriteOperation + operationId: 0 + parentSpanId: 0 + spanId: 4 + spanLayer: Database + startTime: nq 0 + endTime: nq 0 + componentId: 42 + componentName: '' + isError: false + spanType: Exit + peer: mongodb-server:27017 + peerId: 0 + tags: + - {key: db.type, value: MongoDB} + - operationName: MongoDB/FindOperation + operationId: 0 + parentSpanId: 0 + spanId: 5 + spanLayer: Database + startTime: nq 0 + endTime: nq 0 + componentId: 42 + componentName: '' + isError: false + spanType: Exit + peer: mongodb-server:27017 + peerId: 0 + tags: + - {key: db.type, value: MongoDB} + - operationName: MongoDB/MixedBulkWriteOperation + operationId: 0 + parentSpanId: 0 + spanId: 6 + spanLayer: Database + startTime: nq 0 + endTime: nq 0 + componentId: 42 + componentName: '' + isError: false + spanType: Exit + peer: mongodb-server:27017 + peerId: 0 + tags: + - {key: db.type, value: MongoDB} + - operationName: MongoDB/DropDatabaseOperation + operationId: 0 + parentSpanId: 0 + spanId: 7 + spanLayer: Database + startTime: nq 0 + endTime: nq 0 + componentId: 42 + componentName: '' + isError: false + spanType: Exit + peer: mongodb-server:27017 + peerId: 0 + tags: + - {key: db.type, value: MongoDB} + - operationName: /mongodb-case/case/mongodb + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/mongodb-case/case/mongodb'} + - {key: http.method, value: GET} \ No newline at end of file diff --git a/test/plugin/scenarios/mongodb-3.x-scenario/configuration.yml b/test/plugin/scenarios/mongodb-3.x-scenario/configuration.yml new file mode 100644 index 000000000..37c2626e6 --- /dev/null +++ b/test/plugin/scenarios/mongodb-3.x-scenario/configuration.yml @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: jvm +entryService: http://localhost:8080/mongodb-case/case/mongodb +healthCheck: http://localhost:8080/mongodb-case/case/healthCheck +startScript: ./bin/startup.sh +framework: mongodb-driver +dependencies: + mongodb-server: + image: mongo:4.2 + hostname: mongodb-server \ No newline at end of file diff --git a/test/plugin/scenarios/mongodb-3.x-scenario/pom.xml b/test/plugin/scenarios/mongodb-3.x-scenario/pom.xml new file mode 100644 index 000000000..06166219a --- /dev/null +++ b/test/plugin/scenarios/mongodb-3.x-scenario/pom.xml @@ -0,0 +1,140 @@ + + + + + 4.0.0 + + org.apache.skywalking + mongodb-3.x-scenario + 5.0.0 + + skywalking-mongodb-3.x-scenario + + + UTF-8 + 1.8 + + 3.4.0 + + 2.6.2 + 4.3.8.RELEASE + 1.5.2.RELEASE + + + + + org.mongodb + mongodb-driver + ${test.framework.version} + + + + org.springframework.boot + spring-boot-starter + ${spring-boot-version} + + + org.apache.logging.log4j + log4j-api + ${log4j.version} + + + org.apache.logging.log4j + log4j-core + ${log4j.version} + + + org.apache.logging.log4j + log4j-slf4j-impl + ${log4j.version} + + + org.apache.logging.log4j + log4j-jcl + ${log4j.version} + + + org.springframework.boot + spring-boot-starter-tomcat + ${spring-boot-version} + + + org.springframework.boot + spring-boot-starter-web + ${spring-boot-version} + + + + + mongodb-3.x-scenario + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + maven-compiler-plugin + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + + + + + + + + + + spring-snapshots + http://repo.spring.io/snapshot + + + spring-milestones + http://repo.spring.io/milestone + + + \ No newline at end of file diff --git a/test/plugin/scenarios/mongodb-3.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/mongodb-3.x-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000..1436caea3 --- /dev/null +++ b/test/plugin/scenarios/mongodb-3.x-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/mongodb-3.x-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/mongodb-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/mongodb/Application.java b/test/plugin/scenarios/mongodb-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/mongodb/Application.java new file mode 100644 index 000000000..b205ee3bc --- /dev/null +++ b/test/plugin/scenarios/mongodb-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/mongodb/Application.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.mongodb; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} \ No newline at end of file diff --git a/test/plugin/scenarios/mongodb-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/mongodb/controller/CaseController.java b/test/plugin/scenarios/mongodb-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/mongodb/controller/CaseController.java new file mode 100644 index 000000000..b6fadb83d --- /dev/null +++ b/test/plugin/scenarios/mongodb-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/mongodb/controller/CaseController.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.mongodb.controller; + +import com.mongodb.MongoClient; +import com.mongodb.client.FindIterable; +import com.mongodb.client.MongoCollection; +import com.mongodb.client.MongoDatabase; +import org.bson.BsonDocument; +import org.bson.Document; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static com.mongodb.client.model.Filters.eq; + +@RestController +@RequestMapping("/case") +public class CaseController { + + @Value(value = "${mongodb.host}") + private String host; + + @Value(value = "${mongodb.port}") + private Integer port; + + @GetMapping("/healthCheck") + public String health() { + // check connect to mongodb server + try (MongoClient mongoClient = new MongoClient(host, port)) { + return "success"; + } + } + + @RequestMapping("/mongodb") + public String mongoDBCase() { + try ( MongoClient mongoClient = new MongoClient(host, port)) { + MongoDatabase db = mongoClient.getDatabase("test-database"); + // CreateCollectionOperation + db.createCollection("testCollection"); + + MongoCollection collection = db.getCollection("testCollection"); + Document document = Document.parse("{id: 1, name: \"test\"}"); + // MixedBulkWriteOperation + collection.insertOne(document); + + // FindOperation + FindIterable findIterable = collection.find(eq("name", "org")); + findIterable.first(); + + // MixedBulkWriteOperation + collection.updateOne(eq("name", "org"), BsonDocument.parse("{ $set : { \"name\": \"testA\"} }")); + + // FindOperation + findIterable = collection.find(eq("name", "testA")); + findIterable.first(); + + // MixedBulkWriteOperation + collection.deleteOne(eq("id", "1")); + + // DropDatabaseOperation + mongoClient.dropDatabase("test-database"); + } + return "success"; + } +} diff --git a/test/plugin/scenarios/mongodb-3.x-scenario/src/main/resources/application.properties b/test/plugin/scenarios/mongodb-3.x-scenario/src/main/resources/application.properties new file mode 100644 index 000000000..abd9561b6 --- /dev/null +++ b/test/plugin/scenarios/mongodb-3.x-scenario/src/main/resources/application.properties @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +server.port=8080 +server.context-path= /mongodb-case + +mongodb.host= mongodb-server +mongodb.port= 27017 \ No newline at end of file diff --git a/test/plugin/scenarios/mongodb-3.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/mongodb-3.x-scenario/src/main/resources/log4j2.xml new file mode 100644 index 000000000..c370d33b2 --- /dev/null +++ b/test/plugin/scenarios/mongodb-3.x-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + diff --git a/test/plugin/scenarios/mongodb-3.x-scenario/support-version.list b/test/plugin/scenarios/mongodb-3.x-scenario/support-version.list new file mode 100644 index 000000000..09d38b534 --- /dev/null +++ b/test/plugin/scenarios/mongodb-3.x-scenario/support-version.list @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +3.4.0 +3.4.1 +3.4.2 +3.4.3 +3.5.0