From b5ce6981411b6e729dc23ed05bbfa0690ec2e3ec Mon Sep 17 00:00:00 2001 From: daizhenyu <1449308021@qq.com> Date: Mon, 14 Oct 2024 10:01:05 +0800 Subject: [PATCH] xDS router and lb integration test: action Signed-off-by: daizhenyu <1449308021@qq.com> --- .../common/plugin-change-check/action.yml | 2 + .github/actions/common/xds-service/action.yml | 8 +- .../xds-service/xds-router-lb/action.yml | 115 ++++++++++++++++++ .../client-envoy/action.yml | 7 ++ .../sermant-only/action.yml | 7 ++ .../server-envoy/action.yml | 7 ++ .github/workflows/agentcore_service_test.yml | 76 +++++++++++- .../xds-service-test/pom.xml | 43 ++++++- ...pring-cloud-client-sermant-xds-router.yaml | 2 +- .../spring-server-virtureservice.yaml | 2 +- .../xds-service-test/script/zookeeper.yaml | 35 ++++++ .../xds-service-test/spring-client/pom.xml | 12 +- .../spring/client/SpringRouterController.java | 35 ++++++ .../spring-cloud-client/pom.xml | 12 +- .../client/SpringRouterController.java | 41 ++----- .../xds-service-test/spring-server/pom.xml | 3 +- .../spring/server/RouterServerController.java | 2 +- .../xds-service-discovery/pom.xml | 2 +- .../xds-service-discovery-plugin/pom.xml | 2 +- .../xds-service-integration-test/pom.xml | 7 ++ .../xds/service/router/XdsRouterTest.java | 21 ++-- 21 files changed, 364 insertions(+), 77 deletions(-) create mode 100644 .github/actions/scenarios/xds-service/xds-router-lb/action.yml create mode 100644 sermant-integration-tests/xds-service-test/script/zookeeper.yaml diff --git a/.github/actions/common/plugin-change-check/action.yml b/.github/actions/common/plugin-change-check/action.yml index 2a86b843c..96e78249e 100644 --- a/.github/actions/common/plugin-change-check/action.yml +++ b/.github/actions/common/plugin-change-check/action.yml @@ -31,6 +31,8 @@ runs: paths: sermant-agentcore/sermant-agentcore-implement/src/main/java/io/sermant/implement/service/xds sermant-agentcore/sermant-agentcore-core sermant-integration-tests/xds-service-test + sermant-plugins/sermant-router/router-common/** + sermant-plugins/sermant-router/spring-router-plugin/** ./.github/workflows/agentcore_service_test.yml ./.github/actions/common/xds-service ./.github/actions/scenarios/xds-service diff --git a/.github/actions/common/xds-service/action.yml b/.github/actions/common/xds-service/action.yml index 01f44c4b3..525e412f4 100644 --- a/.github/actions/common/xds-service/action.yml +++ b/.github/actions/common/xds-service/action.yml @@ -40,12 +40,8 @@ runs: with: path: sermant-agent-*/ key: ${{ runner.os }}-agent-${{ github.run_id }} - - name: remove xds service product - shell: bash - run: | - rm -rf sermant-integration-tests/xds-service-test/product - name: get cached xds service package uses: actions/cache@v3 with: - path: sermant-integration-tests/xds-service-test/product/ - key: ${{ runner.os }}-xds-service-product-${{ github.run_id }} + path: sermant-integration-tests/xds-service-test/product/sermant-agent-*/ + key: ${{ runner.os }}-xds-service-product-agent-${{ github.run_id }} diff --git a/.github/actions/scenarios/xds-service/xds-router-lb/action.yml b/.github/actions/scenarios/xds-service/xds-router-lb/action.yml new file mode 100644 index 000000000..e2982e205 --- /dev/null +++ b/.github/actions/scenarios/xds-service/xds-router-lb/action.yml @@ -0,0 +1,115 @@ +name: "xDS router an lb Test" +description: "Auto test for xds router and lb with router plugin" +runs: + using: composite + steps: + - name: prepare image + shell: bash + run: | + cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-client/ + cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-cloud-client/ + cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-server/ + mvn package -Dspringboot.version=${{ matrix.springBootVersion }} -Dsnakeyaml.version=${{ matrix.snakeyamlVersion }} -Dspringcloud.version=${{ matrix.springCloudVersion }} -Dhttpclient.version=${{ matrix.httpClientVersion }} -Dokhttp2.version=${{ matrix.okHttp2Version }} -Dhttpclient.async.version=${{ matrix.httpAsyncClientVersion }} -Dokhttp3.version=${{ matrix.okHttp3Version }} -DskipTests -pl spring-client,spring-cloud-client,spring-server -Pxds-router-lb --file \ + sermant-integration-tests/xds-service-test/pom.xml + - name: build docker image + shell: bash + run: | + cd sermant-integration-tests/xds-service-test/product/spring-server/ + minikube image build -t spring-server:1.0.0 . + cd ../spring-client/ + minikube image build -t spring-client:1.0.0 . + cd ../spring-cloud-client/ + minikube image build -t spring-cloud-client:1.0.0 . + eval $(minikube docker-env) + docker images + - name: start zookeeper + shell: bash + run: | + kubectl apply -f sermant-integration-tests/xds-service-test/script/zookeeper.yaml + kubectl wait --for=condition=ready pod -l app=zookeeper --timeout=10s + sleep 15s + - name: start spring-client + shell: bash + run: | + kubectl apply -f sermant-integration-tests/xds-service-test/script/router/deployment/spring-client-sermant-xds-router.yaml + kubectl wait --for=condition=ready pod -l app=spring-client --timeout=10s + sleep 15s + nohup kubectl port-forward svc/spring-client 8080:8080 & + sleep 2s + bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8080/checkStatus 150 + - name: start spring-cloud-client + shell: bash + run: | + kubectl apply -f sermant-integration-tests/xds-service-test/script/router/deployment/spring-cloud-client-sermant-xds-router.yaml + kubectl wait --for=condition=ready pod -l app=spring-cloud-client --timeout=10s + sleep 15s + nohup kubectl port-forward svc/spring-cloud-client 8082:8082 & + sleep 2s + bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8082/router/checkStatus 150 + - name: start spring-server + shell: bash + run: | + kubectl apply -f sermant-integration-tests/xds-service-test/script/router/deployment/spring-server.yaml + kubectl wait --for=condition=ready pod -l app=spring-server --timeout=10s + sleep 15s + nohup kubectl port-forward svc/spring-server 8081:8081 & + sleep 2s + bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8081/hello 150 + pkill -f "kubectl port-forward svc/spring-server" + - name: delivering routing and round-robin lb policy + shell: bash + run: | + kubectl apply -f sermant-integration-tests/xds-service-test/script/router/router-rule/spring-server-destination-robin.yaml + kubectl apply -f sermant-integration-tests/xds-service-test/script/router/router-rule/spring-server-virtureservice.yaml + sleep 10s + - name: test xds router with header and path + shell: bash + run: | + mvn test -Dxds.service.integration.test.type=ROUTER_HEADER_PATH --file \ + sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml + - name: test xds router with round-robin lb policy + shell: bash + run: | + mvn test -Dxds.service.integration.test.type=LB_ROUND_ROBIN --file \ + sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml + - name: test xds router with weighted cluster + shell: bash + run: | + mvn test -Dxds.service.integration.test.type=ROUTER_WEIGHT --file \ + sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml + - name: update lb policy with randmo + shell: bash + run: | + kubectl delete -f sermant-integration-tests/xds-service-test/script/router/router-rule/spring-server-destination-robin.yaml + kubectl apply -f sermant-integration-tests/xds-service-test/script/router/router-rule/spring-server-destination-random.yaml + sleep 10s + - name: test xds router with random lb policy + shell: bash + run: | + mvn test -Dxds.service.integration.test.type=LB_RANDOM --file \ + sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml + - name: restart spring-server with envoy + shell: bash + run: | + kubectl delete -f sermant-integration-tests/xds-service-test/script/router/deployment/spring-server.yaml + sleep 10s + kubectl label namespace default istio-injection=enabled + kubectl apply -f sermant-integration-tests/xds-service-test/script/router/deployment/spring-server.yaml + kubectl wait --for=condition=ready pod -l app=spring-server --timeout=10s + sleep 15s + nohup kubectl port-forward svc/spring-server 8081:8081 & + sleep 2s + bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8081/hello 150 + pkill -f "kubectl port-forward svc/spring-server" + kubectl label namespace default istio-injection- + - name: test xds router with envoy + shell: bash + run: | + mvn test -Dxds.service.integration.test.type=ROUTER_HEADER_PATH --file \ + sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml + - name: close all service + shell: bash + run: | + kubectl delete -f sermant-integration-tests/xds-service-test/script/router/deployment/spring-client-sermant-xds-router.yaml + kubectl delete -f sermant-integration-tests/xds-service-test/script/router/deployment/spring-cloud-client-sermant-xds-router.yaml + kubectl delete -f sermant-integration-tests/xds-service-test/script/router/deployment/spring-server.yaml diff --git a/.github/actions/scenarios/xds-service/xds-service-discovery/client-envoy/action.yml b/.github/actions/scenarios/xds-service/xds-service-discovery/client-envoy/action.yml index 30f2215d7..9cb0187ff 100644 --- a/.github/actions/scenarios/xds-service/xds-service-discovery/client-envoy/action.yml +++ b/.github/actions/scenarios/xds-service/xds-service-discovery/client-envoy/action.yml @@ -3,6 +3,13 @@ description: "Auto test for xds service discovery with Client Using Envoy" runs: using: composite steps: + - name: prepare image + shell: bash + run: | + cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-client/ + cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-server/ + mvn package -DskipTests -pl spring-client,spring-server -Pxds-discovery --file \ + sermant-integration-tests/xds-service-test/pom.xml - name: build docker image shell: bash run: | diff --git a/.github/actions/scenarios/xds-service/xds-service-discovery/sermant-only/action.yml b/.github/actions/scenarios/xds-service/xds-service-discovery/sermant-only/action.yml index 3dabee73d..9879780c4 100644 --- a/.github/actions/scenarios/xds-service/xds-service-discovery/sermant-only/action.yml +++ b/.github/actions/scenarios/xds-service/xds-service-discovery/sermant-only/action.yml @@ -3,6 +3,13 @@ description: "Auto test for xds service discovery" runs: using: composite steps: + - name: prepare image + shell: bash + run: | + cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-client/ + cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-server/ + mvn package -DskipTests -pl spring-client,spring-server -Pxds-discovery --file \ + sermant-integration-tests/xds-service-test/pom.xml - name: build docker image shell: bash run: | diff --git a/.github/actions/scenarios/xds-service/xds-service-discovery/server-envoy/action.yml b/.github/actions/scenarios/xds-service/xds-service-discovery/server-envoy/action.yml index 290efbd02..416706fbb 100644 --- a/.github/actions/scenarios/xds-service/xds-service-discovery/server-envoy/action.yml +++ b/.github/actions/scenarios/xds-service/xds-service-discovery/server-envoy/action.yml @@ -3,6 +3,13 @@ description: "Auto test for xds service discovery with server using envoy" runs: using: composite steps: + - name: prepare image + shell: bash + run: | + cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-client/ + cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-server/ + mvn package -DskipTests -pl spring-client,spring-server -Pxds-discovery --file \ + sermant-integration-tests/xds-service-test/pom.xml - name: build docker image shell: bash run: | diff --git a/.github/workflows/agentcore_service_test.yml b/.github/workflows/agentcore_service_test.yml index 6e1246178..d527f536d 100644 --- a/.github/workflows/agentcore_service_test.yml +++ b/.github/workflows/agentcore_service_test.yml @@ -20,6 +20,8 @@ on: - '.github/actions/common/plugin-change-check/action.yml' - '.github/actions/common/entry/action.yml' - '.github/actions/common/exit/action.yml' + - 'sermant-plugins/sermant-router/router-common/**' + - 'sermant-plugins/sermant-router/spring-router-plugin/**' concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ github.head_ref }} cancel-in-progress: true @@ -103,14 +105,13 @@ jobs: - name: cache xds service package uses: actions/cache@v3 with: - path: sermant-integration-tests/xds-service-test/product/ - key: ${{ runner.os }}-xds-service-product-${{ github.run_id }} + path: sermant-integration-tests/xds-service-test/product/sermant-agent-*/ + key: ${{ runner.os }}-xds-service-product-agent-${{ github.run_id }} - name: package agent run: | sed -i '/sermant-backend/d' pom.xml sed -i '/sermant-injector/d' pom.xml mvn package -DskipTests -Ptest --file pom.xml - cp -r sermant-integration-tests/xds-service-test/product/spring-client/agent sermant-integration-tests/xds-service-test/product/spring-server/ mkdir -p sermant-agent-${{ env.sermantVersion }}/agent/pluginPackage/agentcore-test-plugin/plugin mkdir -p sermant-agent-${{ env.sermantVersion }}/agent/pluginPackage/dynamic-test-first-plugin/plugin mkdir -p sermant-agent-${{ env.sermantVersion }}/agent/pluginPackage/dynamic-test-second-plugin/plugin @@ -194,3 +195,72 @@ jobs: uses: ./.github/actions/common/xds-service - name: xds service discovery uses: ./.github/actions/scenarios/xds-service/xds-service-discovery/client-envoy + test-for-xds-router-lb: + name: Test for xds router and lb with router plugin + runs-on: ubuntu-latest + if: needs.set-execution-conditions.outputs.enableXdsServicAction == 'true' + needs: [set-execution-conditions, build-agent-and-cache] + strategy: + matrix: + include: + - springBootVersion: "2.0.2.RELEASE" + snakeyamlVersion: "1.19" + springCloudVersion: "Finchley.RELEASE" + httpClientVersion: "4.4" + okHttp2Version: "2.2.0" + okHttp3Version: "3.5.0" + httpAsyncClientVersion: "4.0.1" + - springBootVersion: "2.1.0.RELEASE" + snakeyamlVersion: "1.23" + springCloudVersion: "Greenwich.RELEASE" + httpClientVersion: "4.4.1" + okHttp2Version: "2.3.0" + okHttp3Version: "3.9.1" + httpAsyncClientVersion: "4.0.2" + - springBootVersion: "2.2.0.RELEASE" + snakeyamlVersion: "1.25" + springCloudVersion: "Hoxton.RELEASE" + httpClientVersion: "4.5" + okHttp2Version: "2.4.0" + okHttp3Version: "3.12.13" + httpAsyncClientVersion: "4.1" + - springBootVersion: "2.3.0.RELEASE" + snakeyamlVersion: "1.26" + springCloudVersion: "Hoxton.RELEASE" + httpClientVersion: "4.5.3" + okHttp2Version: "2.5.0" + okHttp3Version: "3.14.9" + httpAsyncClientVersion: "4.1.1" + - springBootVersion: "2.4.0" + snakeyamlVersion: "1.27" + springCloudVersion: "2020.0.0" + httpClientVersion: "4.5.7" + okHttp2Version: "2.6.0" + okHttp3Version: "4.2.2" + httpAsyncClientVersion: "4.1.2" + - springBootVersion: "2.6.2" + snakeyamlVersion: "1.29" + springCloudVersion: "2021.0.0" + httpClientVersion: "4.5.10" + okHttp2Version: "2.7.3" + okHttp3Version: "4.7.2" + httpAsyncClientVersion: "4.1.3" + - springBootVersion: "2.7.17" + snakeyamlVersion: "1.30" + springCloudVersion: "2021.0.3" + httpClientVersion: "4.5.13" + okHttp2Version: "2.7.5" + okHttp3Version: "4.12.0" + httpAsyncClientVersion: "4.1.5" + fail-fast: false + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 100 + - name: set java version to environment + run: | + echo "javaVersion=8" >> $GITHUB_ENV + - name: xds common operation + uses: ./.github/actions/common/xds-service + - name: xds router and lb test + uses: ./.github/actions/scenarios/xds-service/xds-router-lb diff --git a/sermant-integration-tests/xds-service-test/pom.xml b/sermant-integration-tests/xds-service-test/pom.xml index 6aef01111..f1a0732ce 100644 --- a/sermant-integration-tests/xds-service-test/pom.xml +++ b/sermant-integration-tests/xds-service-test/pom.xml @@ -15,12 +15,32 @@ 8 8 - 2.7.17 + 2.7.17 2021.0.3 + 4.5.13 + 2.7.5 + 4.1.5 + 4.9.3 + 1.29 + + org.springframework.boot + spring-boot-starter-web + ${springboot.version} + + + org.springframework.boot + spring-boot-configuration-processor + ${springboot.version} + + + org.yaml + snakeyaml + ${snakeyaml.version} + org.springframework.cloud spring-cloud-dependencies @@ -32,9 +52,24 @@ - spring-client - spring-server xds-service-discovery - spring-cloud-client + + + + xds-discovery + + spring-client + spring-server + + + + xds-router-lb + + spring-client + spring-server + spring-cloud-client + + + diff --git a/sermant-integration-tests/xds-service-test/script/router/deployment/spring-cloud-client-sermant-xds-router.yaml b/sermant-integration-tests/xds-service-test/script/router/deployment/spring-cloud-client-sermant-xds-router.yaml index b5de30f02..23e6dd961 100644 --- a/sermant-integration-tests/xds-service-test/script/router/deployment/spring-cloud-client-sermant-xds-router.yaml +++ b/sermant-integration-tests/xds-service-test/script/router/deployment/spring-cloud-client-sermant-xds-router.yaml @@ -23,7 +23,7 @@ spec: value: "false" - name: agent_service_xds_service_enable value: "true" - - name: router_plugin_enabled-xds-route + - name: router_plugin_enabled_xds_route value: "true" - name: ZOOKEEPER_IP value: "zookeeper.default.svc.cluster.local" diff --git a/sermant-integration-tests/xds-service-test/script/router/router-rule/spring-server-virtureservice.yaml b/sermant-integration-tests/xds-service-test/script/router/router-rule/spring-server-virtureservice.yaml index bddefb5d1..daa7ee9be 100644 --- a/sermant-integration-tests/xds-service-test/script/router/router-rule/spring-server-virtureservice.yaml +++ b/sermant-integration-tests/xds-service-test/script/router/router-rule/spring-server-virtureservice.yaml @@ -39,7 +39,7 @@ spec: version: exact: base uri: - exact: /router + prefix: / ignoreUriCase: false route: - destination: diff --git a/sermant-integration-tests/xds-service-test/script/zookeeper.yaml b/sermant-integration-tests/xds-service-test/script/zookeeper.yaml new file mode 100644 index 000000000..aab6f79b2 --- /dev/null +++ b/sermant-integration-tests/xds-service-test/script/zookeeper.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: zookeeper + labels: + app: zookeeper +spec: + replicas: 1 + selector: + matchLabels: + app: zookeeper + template: + metadata: + labels: + app: zookeeper + spec: + containers: + - name: zookeeper + image: zookeeper:3.7.1 + ports: + - containerPort: 2181 +--- +apiVersion: v1 +kind: Service +metadata: + name: zookeeper +spec: + type: ClusterIP + ports: + - name: zk + port: 2181 + targetPort: 2181 + protocol: TCP + selector: + app: zookeeper diff --git a/sermant-integration-tests/xds-service-test/spring-client/pom.xml b/sermant-integration-tests/xds-service-test/spring-client/pom.xml index a44b777a3..1fa100906 100644 --- a/sermant-integration-tests/xds-service-test/spring-client/pom.xml +++ b/sermant-integration-tests/xds-service-test/spring-client/pom.xml @@ -14,20 +14,22 @@ 8 8 - 4.5.13 - 2.7.5 org.springframework.boot spring-boot-starter-web - ${spring.version} org.apache.httpcomponents httpclient - ${httpclient.version} + 4.5.13 + + + org.apache.httpcomponents + httpasyncclient + ${httpclient.async.version} com.squareup.okhttp @@ -41,7 +43,7 @@ org.springframework.boot spring-boot-maven-plugin - ${spring.version} + ${springboot.version} io.sermant.demo.spring.client.SpringClientApplication spring-client diff --git a/sermant-integration-tests/xds-service-test/spring-client/src/main/java/io/sermant/demo/spring/client/SpringRouterController.java b/sermant-integration-tests/xds-service-test/spring-client/src/main/java/io/sermant/demo/spring/client/SpringRouterController.java index af50348dd..4a6738fd4 100644 --- a/sermant-integration-tests/xds-service-test/spring-client/src/main/java/io/sermant/demo/spring/client/SpringRouterController.java +++ b/sermant-integration-tests/xds-service-test/spring-client/src/main/java/io/sermant/demo/spring/client/SpringRouterController.java @@ -20,10 +20,18 @@ import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.nio.client.CloseableHttpAsyncClient; +import org.apache.http.impl.nio.client.HttpAsyncClients; +import org.apache.http.util.EntityUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.io.IOException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; /** * SpringRouterController @@ -68,6 +76,33 @@ public String testOkHttp2Routing(String host, String version) { } } + /** + * test http async client routing + * + * @param host host + * @param version version + * @return result + */ + @RequestMapping("httpAsyncClient") + public String testHttpAsyncClientRouting(String host, String version) { + String url = buildUrl(host); + try (CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault()) { + httpclient.start(); + HttpGet request = new HttpGet(url); + request.setHeader(VERSION, version); + Future future = httpclient.execute(request, null); + HttpResponse response = future.get(); + int statusCode = response.getStatusLine().getStatusCode(); + if (statusCode == HttpStatus.SC_OK) { + return EntityUtils.toString(response.getEntity()); + } else { + return ""; + } + } catch (IOException | InterruptedException | ExecutionException e) { + return ""; + } + } + private String buildUrl(String host) { StringBuilder urlBuilder = new StringBuilder(); urlBuilder.append("http://"); diff --git a/sermant-integration-tests/xds-service-test/spring-cloud-client/pom.xml b/sermant-integration-tests/xds-service-test/spring-cloud-client/pom.xml index ca1b2b068..7f9b803b6 100644 --- a/sermant-integration-tests/xds-service-test/spring-cloud-client/pom.xml +++ b/sermant-integration-tests/xds-service-test/spring-cloud-client/pom.xml @@ -14,21 +14,16 @@ 8 8 - 4.5.13 - 4.1.4 - 4.9.3 org.springframework.boot spring-boot-starter-web - ${spring.version} org.springframework.boot spring-boot-configuration-processor - ${spring.version} org.springframework.cloud @@ -44,11 +39,6 @@ okhttp ${okhttp3.version} - - org.apache.httpcomponents - httpasyncclient - ${httpclient.async.version} - @@ -56,7 +46,7 @@ org.springframework.boot spring-boot-maven-plugin - ${spring.version} + ${springboot.version} io.sermant.demo.springcloud.client.SpringCloudClientApplication spring-cloud-client diff --git a/sermant-integration-tests/xds-service-test/spring-cloud-client/src/main/java/io/sermant/demo/springcloud/client/SpringRouterController.java b/sermant-integration-tests/xds-service-test/spring-cloud-client/src/main/java/io/sermant/demo/springcloud/client/SpringRouterController.java index 1df321d0e..192d48ee4 100644 --- a/sermant-integration-tests/xds-service-test/spring-cloud-client/src/main/java/io/sermant/demo/springcloud/client/SpringRouterController.java +++ b/sermant-integration-tests/xds-service-test/spring-cloud-client/src/main/java/io/sermant/demo/springcloud/client/SpringRouterController.java @@ -21,8 +21,6 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.nio.client.CloseableHttpAsyncClient; -import org.apache.http.impl.nio.client.HttpAsyncClients; import org.apache.http.util.EntityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; @@ -38,8 +36,6 @@ import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; /** * SpringRouterController @@ -59,6 +55,16 @@ public class SpringRouterController { @Autowired private RestTemplate restTemplate; + /** + * check service status + * + * @return result + */ + @RequestMapping("checkStatus") + public String checkStatus() { + return "ok"; + } + /** * test httpclient routing * @@ -130,33 +136,6 @@ public String testJdkHttpRouting(String host, String version) { } } - /** - * test http async client routing - * - * @param host host - * @param version version - * @return result - */ - @RequestMapping("httpAsyncClient") - public String testHttpAsyncClientRouting(String host, String version) { - String url = buildUrl(host); - try (CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault()) { - httpclient.start(); - HttpGet request = new HttpGet(url); - request.setHeader(VERSION, version); - Future future = httpclient.execute(request, null); - HttpResponse response = future.get(); - int statusCode = response.getStatusLine().getStatusCode(); - if (statusCode == HttpStatus.SC_OK) { - return EntityUtils.toString(response.getEntity()); - } else { - return ""; - } - } catch (IOException | InterruptedException | ExecutionException e) { - return ""; - } - } - /** * test okhttp3 routing * diff --git a/sermant-integration-tests/xds-service-test/spring-server/pom.xml b/sermant-integration-tests/xds-service-test/spring-server/pom.xml index 62e66c05a..6d7a20ef5 100644 --- a/sermant-integration-tests/xds-service-test/spring-server/pom.xml +++ b/sermant-integration-tests/xds-service-test/spring-server/pom.xml @@ -20,7 +20,6 @@ org.springframework.boot spring-boot-starter-web - ${spring.version} org.springframework.cloud @@ -33,7 +32,7 @@ org.springframework.boot spring-boot-maven-plugin - ${spring.version} + ${springboot.version} io.sermant.demo.spring.server.SpringServerApplication spring-server diff --git a/sermant-integration-tests/xds-service-test/spring-server/src/main/java/io/sermant/demo/spring/server/RouterServerController.java b/sermant-integration-tests/xds-service-test/spring-server/src/main/java/io/sermant/demo/spring/server/RouterServerController.java index 1e8d6ec27..eaa5c6e81 100644 --- a/sermant-integration-tests/xds-service-test/spring-server/src/main/java/io/sermant/demo/spring/server/RouterServerController.java +++ b/sermant-integration-tests/xds-service-test/spring-server/src/main/java/io/sermant/demo/spring/server/RouterServerController.java @@ -28,7 +28,7 @@ **/ @RestController public class RouterServerController { - @Value("${SERVER_VERSION:1.0.0}") + @Value("${SERVER_VERSION:v1}") private String version; /** diff --git a/sermant-integration-tests/xds-service-test/xds-service-discovery/pom.xml b/sermant-integration-tests/xds-service-test/xds-service-discovery/pom.xml index 6c59a1fd6..bc85d4efe 100644 --- a/sermant-integration-tests/xds-service-test/xds-service-discovery/pom.xml +++ b/sermant-integration-tests/xds-service-test/xds-service-discovery/pom.xml @@ -13,7 +13,7 @@ pom - ${pom.basedir}/../product/spring-client + ${pom.basedir}/../product/sermant-agent-${project.version} xds-service-discovery ${output.basedir}/agent/pluginPackage undefined diff --git a/sermant-integration-tests/xds-service-test/xds-service-discovery/xds-service-discovery-plugin/pom.xml b/sermant-integration-tests/xds-service-test/xds-service-discovery/xds-service-discovery-plugin/pom.xml index 6db72a803..c40246112 100644 --- a/sermant-integration-tests/xds-service-test/xds-service-discovery/xds-service-discovery-plugin/pom.xml +++ b/sermant-integration-tests/xds-service-test/xds-service-discovery/xds-service-discovery-plugin/pom.xml @@ -12,7 +12,7 @@ xds-service-discovery-plugin - ${pom.basedir}/../../product/spring-client + ${pom.basedir}/../../product/sermant-agent-${project.version} xds-service-discovery plugin false diff --git a/sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml b/sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml index 3b4f6695d..54df56a05 100644 --- a/sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml +++ b/sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml @@ -16,6 +16,9 @@ 8 4.5.13 1.2 + 1.2.13 + 1.7.35 + 5.8.1 3.0.0 @@ -23,6 +26,7 @@ org.junit.jupiter junit-jupiter + ${jupiter.version} test @@ -34,16 +38,19 @@ ch.qos.logback logback-core + ${logback.version} test ch.qos.logback logback-classic + ${logback.version} test org.slf4j slf4j-api + ${slf4j.version} test diff --git a/sermant-integration-tests/xds-service-test/xds-service-integration-test/src/test/java/io/sermant/xds/service/router/XdsRouterTest.java b/sermant-integration-tests/xds-service-test/xds-service-integration-test/src/test/java/io/sermant/xds/service/router/XdsRouterTest.java index 980abfae2..1b4fa7922 100644 --- a/sermant-integration-tests/xds-service-test/xds-service-integration-test/src/test/java/io/sermant/xds/service/router/XdsRouterTest.java +++ b/sermant-integration-tests/xds-service-test/xds-service-integration-test/src/test/java/io/sermant/xds/service/router/XdsRouterTest.java @@ -33,16 +33,16 @@ public class XdsRouterTest { * test xds router with header and path */ @Test - @EnabledIfSystemProperty(named = "xds.service.integration.test.type", matches = "ROUTER_HEADER") + @EnabledIfSystemProperty(named = "xds.service.integration.test.type", matches = "ROUTER_HEADER_PATH") public void testRouterWithHeaderAndPath() { Assertions.assertEquals("v1", HttpRequestUtils.doGet("http://127.0.0.1:8080/router/okHttp2?host=spring-server&version=v1")); + Assertions.assertEquals("v1", + HttpRequestUtils.doGet("http://127.0.0.1:8080/router/httpAsyncClient?host=spring-server&version=v1")); Assertions.assertEquals("v1", HttpRequestUtils.doGet("http://127.0.0.1:8082/router/httpClient?host=spring-server&version=v1")); Assertions.assertEquals("v1", HttpRequestUtils.doGet("http://127.0.0.1:8082/router/jdkHttp?host=spring-server&version=v1")); - Assertions.assertEquals("v1", - HttpRequestUtils.doGet("http://127.0.0.1:8082/router/httpAsyncClient?host=spring-server&version=v1")); Assertions.assertEquals("v1", HttpRequestUtils.doGet("http://127.0.0.1:8082/router/okHttp3?host=spring-server&version=v1")); Assertions.assertEquals("v1", @@ -53,7 +53,7 @@ public void testRouterWithHeaderAndPath() { * test xds router with random lb */ @Test - @EnabledIfSystemProperty(named = "xds.service.integration.test.type", matches = "ROUTER_RANDOM") + @EnabledIfSystemProperty(named = "xds.service.integration.test.type", matches = "LB_RANDOM") public void testRouterWithRandom() { int[][] results = new int[5][2]; @@ -67,7 +67,8 @@ public void testRouterWithRandom() { countCalls(results, 2, HttpRequestUtils.doGet("http://127.0.0.1:8082/router/jdkHttp?host=spring-server&version=v2")); countCalls(results, 3, - HttpRequestUtils.doGet("http://127.0.0.1:8082/router/httpAsyncClient?host=spring-server&version=v2")); + HttpRequestUtils.doGet("http://127.0.0.1:8080/router/httpAsyncClient?host=spring-server&version" + + "=v2")); countCalls(results, 4, HttpRequestUtils.doGet("http://127.0.0.1:8082/router/okHttp3?host=spring-server&version=v2")); } @@ -82,7 +83,7 @@ public void testRouterWithRandom() { * test xds router with round-robin lb */ @Test - @EnabledIfSystemProperty(named = "xds.service.integration.test.type", matches = "ROUND_ROBIN") + @EnabledIfSystemProperty(named = "xds.service.integration.test.type", matches = "LB_ROUND_ROBIN") public void testRouterWithRoundRobin() { Assertions.assertNotEquals( HttpRequestUtils.doGet("http://127.0.0.1:8080/router/okHttp2?host=spring-server&version=v2"), @@ -94,8 +95,8 @@ public void testRouterWithRoundRobin() { HttpRequestUtils.doGet("http://127.0.0.1:8082/router/jdkHttp?host=spring-server&version=v2"), HttpRequestUtils.doGet("http://127.0.0.1:8082/router/jdkHttp?host=spring-server&version=v2")); Assertions.assertNotEquals( - HttpRequestUtils.doGet("http://127.0.0.1:8082/router/httpAsyncClient?host=spring-server&version=v2"), - HttpRequestUtils.doGet("http://127.0.0.1:8082/router/httpAsyncClient?host=spring-server&version=v2")); + HttpRequestUtils.doGet("http://127.0.0.1:8080/router/httpAsyncClient?host=spring-server&version=v2"), + HttpRequestUtils.doGet("http://127.0.0.1:8080/router/httpAsyncClient?host=spring-server&version=v2")); Assertions.assertNotEquals( HttpRequestUtils.doGet("http://127.0.0.1:8082/router/okHttp3?host=spring-server&version=v2"), HttpRequestUtils.doGet("http://127.0.0.1:8082/router/okHttp3?host=spring-server&version=v2")); @@ -121,7 +122,7 @@ public void testRouterWithWeight() { HttpRequestUtils.doGet("http://127.0.0.1:8082/router/jdkHttp?host=spring-server&version=base")); Assertions.assertEquals("v2", HttpRequestUtils - .doGet("http://127.0.0.1:8082/router/httpAsyncClient?host=spring-server&version=base")); + .doGet("http://127.0.0.1:8080/router/httpAsyncClient?host=spring-server&version=base")); Assertions.assertEquals("v2", HttpRequestUtils.doGet("http://127.0.0.1:8082/router/okHttp3?host=spring-server&version=base")); Assertions.assertEquals("v2", @@ -143,7 +144,7 @@ private void countCalls(int[][] results, int index, String result) { private boolean isRandom(int[][] results, int index) { int differenceValue = Math.abs(results[index][0] - results[index][1]); - if (differenceValue <= 20) { + if (differenceValue <= 30) { return true; } return false;