diff --git a/.github/workflows/plugins-test.yaml b/.github/workflows/plugins-test.yaml index f5b59f7f6..0fb8c5d57 100644 --- a/.github/workflows/plugins-test.yaml +++ b/.github/workflows/plugins-test.yaml @@ -512,3 +512,28 @@ jobs: run: ./mvnw -f test/plugin/pom.xml clean package -DskipTests docker:build -DBUILD_NO=local >/dev/null - name: Run mysql 5.1.2-8.0.15 (53) run: bash test/plugin/run.sh mysql-scenario + + LETTUCE: + runs-on: ubuntu-18.04 + timeout-minutes: 90 + strategy: + fail-fast: true + steps: + - uses: actions/checkout@v1 + with: + submodules: true + - uses: actions/cache@v1 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - uses: actions/setup-java@v1 + with: + java-version: 8 + - name: Build SkyWalking Agent + run: ./mvnw clean package -DskipTests -Pagent >/dev/null + - name: Build the Docker image + run: ./mvnw -f test/plugin/pom.xml clean package -DskipTests docker:build -DBUILD_NO=local >/dev/null + - name: Run lettuce-scenario 5.x (17) + run: bash test/plugin/run.sh lettuce-scenario \ No newline at end of file diff --git a/test/plugin/scenarios/lettuce-scenario/bin/startup.sh b/test/plugin/scenarios/lettuce-scenario/bin/startup.sh new file mode 100644 index 000000000..32d2ba464 --- /dev/null +++ b/test/plugin/scenarios/lettuce-scenario/bin/startup.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# 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. + +home="$(cd "$(dirname $0)"; pwd)" + +java -Dredis.host=${REDIS_SERVERS} -jar ${agent_opts} ${home}/../libs/lettuce-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/lettuce-scenario/config/expectedData.yaml b/test/plugin/scenarios/lettuce-scenario/config/expectedData.yaml new file mode 100644 index 000000000..a5eebc583 --- /dev/null +++ b/test/plugin/scenarios/lettuce-scenario/config/expectedData.yaml @@ -0,0 +1,78 @@ +# 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: + - {lettuce-scenario: 2} + instances: + - {lettuce-scenario: 1} + operationNames: + - lettuce-scenario: [/lettuce-scenario/case/lettuce-case, /lettuce-scenario/case/healthCheck] + heartbeat: [] +segmentItems: + - applicationCode: lettuce-scenario + segmentSize: nq 0 + segments: + - segmentId: not null + spans: + - operationName: Lettuce/GET + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Cache + startTime: not null + endTime: not null + componentId: 57 + componentName: '' + isError: false + spanType: Exit + peer: not null + peerId: 0 + tags: + - {key: db.type, value: Redis} + - {key: db.statement, value: GET} + - operationName: Lettuce/BATCH_WRITE + operationId: 0 + parentSpanId: 0 + spanId: 2 + spanLayer: Cache + startTime: not null + endTime: not null + componentId: 57 + componentName: '' + isError: false + spanType: Exit + peer: not null + peerId: 0 + tags: + - {key: db.type, value: Redis} + - {key: db.statement, value: SET;SET;} + - operationName: /lettuce-scenario/case/lettuce-case + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: not null + endTime: not null + componentId: 1 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: not null} + - {key: http.method, value: GET} \ No newline at end of file diff --git a/test/plugin/scenarios/lettuce-scenario/configuration.yml b/test/plugin/scenarios/lettuce-scenario/configuration.yml new file mode 100644 index 000000000..725030f95 --- /dev/null +++ b/test/plugin/scenarios/lettuce-scenario/configuration.yml @@ -0,0 +1,31 @@ +# 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/lettuce-scenario/case/lettuce-case +healthCheck: http://localhost:8080/lettuce-scenario/case/healthCheck +startScript: ./bin/startup.sh +framework: lettuce +runningMode: with_optional +withPlugins: apm-lettuce-5.x-plugin-*.jar +environment: + - REDIS_SERVERS=redis-server:6379 +depends_on: + - redis-server +dependencies: + redis-server: + image: redis:3.2.9-alpine + hostname: redis-server \ No newline at end of file diff --git a/test/plugin/scenarios/lettuce-scenario/pom.xml b/test/plugin/scenarios/lettuce-scenario/pom.xml new file mode 100644 index 000000000..49203a35a --- /dev/null +++ b/test/plugin/scenarios/lettuce-scenario/pom.xml @@ -0,0 +1,144 @@ + + + + 4.0.0 + + org.apache.skywalking + lettuce-scenario + 5.0.0 + + + UTF-8 + 1.8 + 5.1.3.RELEASE + ${test.framework.version} + 2.6.2 + 4.3.8.RELEASE + 1.5.2.RELEASE + 3.4.2 + + + skywalking-lettuce-scenario + + + + com.squareup.okhttp3 + okhttp + ${okhttp.version} + + + io.lettuce + lettuce-core + ${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} + + + + + lettuce-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 + + ./target/ + + + + + + + + + + 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/lettuce-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/lettuce-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000..d8d225bdf --- /dev/null +++ b/test/plugin/scenarios/lettuce-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/lettuce-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/lettuce-scenario/src/main/java/org/apache/skywalking/apm/testcase/lettuce/Application.java b/test/plugin/scenarios/lettuce-scenario/src/main/java/org/apache/skywalking/apm/testcase/lettuce/Application.java new file mode 100644 index 000000000..7fccbab24 --- /dev/null +++ b/test/plugin/scenarios/lettuce-scenario/src/main/java/org/apache/skywalking/apm/testcase/lettuce/Application.java @@ -0,0 +1,35 @@ +/* + * 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.lettuce; + +import org.springframework.boot.SpringApplication; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + try { + SpringApplication.run(Application.class, args); + } catch (Exception e) { + // Never do this + } + } +} diff --git a/test/plugin/scenarios/lettuce-scenario/src/main/java/org/apache/skywalking/apm/testcase/lettuce/controller/LettuceController.java b/test/plugin/scenarios/lettuce-scenario/src/main/java/org/apache/skywalking/apm/testcase/lettuce/controller/LettuceController.java new file mode 100644 index 000000000..2f6e97a5d --- /dev/null +++ b/test/plugin/scenarios/lettuce-scenario/src/main/java/org/apache/skywalking/apm/testcase/lettuce/controller/LettuceController.java @@ -0,0 +1,73 @@ +/* + * 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.lettuce.controller; + +import io.lettuce.core.LettuceFutures; +import io.lettuce.core.RedisClient; +import io.lettuce.core.RedisFuture; +import io.lettuce.core.api.StatefulRedisConnection; +import io.lettuce.core.api.async.RedisAsyncCommands; +import io.lettuce.core.api.sync.RedisCommands; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +@Controller +@RequestMapping("/case") +@PropertySource("classpath:application.properties") +public class LettuceController { + + @Value("${redis.servers:127.0.0.1:6379}") + private String address; + + @RequestMapping("/lettuce-case") + @ResponseBody + public String lettuceCase() { + RedisClient redisClient = RedisClient.create("redis://" + address); + StatefulRedisConnection connection0 = redisClient.connect(); + RedisCommands syncCommand = connection0.sync(); + syncCommand.get("key"); + + StatefulRedisConnection connection1 = redisClient.connect(); + RedisAsyncCommands asyncCommands = connection1.async(); + asyncCommands.setAutoFlushCommands(false); + List> futures = new ArrayList<>(); + futures.add(asyncCommands.set("key0", "value0")); + futures.add(asyncCommands.set("key1", "value1")); + asyncCommands.flushCommands(); + LettuceFutures.awaitAll(5, TimeUnit.SECONDS, futures.toArray(new RedisFuture[futures.size()])); + + connection0.close(); + connection1.close(); + redisClient.shutdown(); + return "Success"; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() { + return "healthCheck"; + } +} diff --git a/test/plugin/scenarios/lettuce-scenario/src/main/resources/application.properties b/test/plugin/scenarios/lettuce-scenario/src/main/resources/application.properties new file mode 100644 index 000000000..ac84e54de --- /dev/null +++ b/test/plugin/scenarios/lettuce-scenario/src/main/resources/application.properties @@ -0,0 +1,20 @@ +# +# 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.contextPath=/lettuce-scenario diff --git a/test/plugin/scenarios/lettuce-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/lettuce-scenario/src/main/resources/log4j2.xml new file mode 100644 index 000000000..9849ed5a8 --- /dev/null +++ b/test/plugin/scenarios/lettuce-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/lettuce-scenario/support-version.list b/test/plugin/scenarios/lettuce-scenario/support-version.list new file mode 100644 index 000000000..5e897a8f8 --- /dev/null +++ b/test/plugin/scenarios/lettuce-scenario/support-version.list @@ -0,0 +1,33 @@ +# 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. + +5.2.1.RELEASE +5.2.0.RELEASE +5.1.8.RELEASE +5.1.7.RELEASE +5.1.6.RELEASE +5.1.5.RELEASE +5.1.4.RELEASE +5.1.3.RELEASE +5.1.2.RELEASE +5.1.1.RELEASE +5.1.0.RELEASE +5.0.5.RELEASE +5.0.4.RELEASE +5.0.3.RELEASE +5.0.2.RELEASE +5.0.1.RELEASE +5.0.0.RELEASE \ No newline at end of file