Skip to content

Commit e9f7cb7

Browse files
committed
xDS Service Discovery Integration Test
Signed-off-by: daizhenyu <1449308021@qq.com>
1 parent 31b0b97 commit e9f7cb7

File tree

37 files changed

+1879
-15
lines changed

37 files changed

+1879
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: "xDS Service Common Test"
2+
description: "Auto common test for xds service"
3+
runs:
4+
using: composite
5+
steps:
6+
- name: start minikube
7+
uses: medyagh/setup-minikube@latest
8+
id: minikube
9+
with:
10+
minikube-version: 1.31.2
11+
driver: docker
12+
container-runtime: docker
13+
- name: Delay for 10 seconds to ready k8s
14+
shell: bash
15+
run: sleep 10s
16+
- name: check k8s
17+
shell: bash
18+
run: |
19+
kubectl cluster-info
20+
kubectl get pods -n kube-system
21+
echo "k8s version:" $(kubectl version)
22+
- name: deploy istio
23+
shell: bash
24+
run: |
25+
curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.21.4 sh -
26+
istio-1.21.4/bin/istioctl install -f sermant-integration-tests/xds-service-test/script/istio-operator.yaml --skip-confirmation
27+
- name: Delay for 10 seconds to ready istio
28+
shell: bash
29+
run: |
30+
sleep 10s
31+
kubectl get pods -n istio-system
32+
- name: Set up JDK ${{ env.javaVersion }}
33+
uses: actions/setup-java@v3
34+
with:
35+
java-version: ${{ env.javaVersion }}
36+
distribution: 'adopt'
37+
cache: maven
38+
- name: get cached agent
39+
uses: actions/cache@v3
40+
with:
41+
path: sermant-agent-*/
42+
key: ${{ runner.os }}-agent-${{ github.run_id }}
43+
- name: remove xds service product
44+
shell: bash
45+
run: |
46+
rm -rf sermant-integration-tests/xds-service-test/product
47+
- name: get cached xds service package
48+
uses: actions/cache@v3
49+
with:
50+
path: sermant-integration-tests/xds-service-test/product/
51+
key: ${{ runner.os }}-xds-service-product-${{ github.run_id }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: "xDS Service Discovery Test with Client Using Envoy"
2+
description: "Auto test for xds service discovery with Client Using Envoy"
3+
runs:
4+
using: composite
5+
steps:
6+
- name: build docker image
7+
shell: bash
8+
run: |
9+
cd sermant-integration-tests/xds-service-test/product/spring-server/
10+
minikube image build -t spring-server:1.0.0 .
11+
cd ../spring-client/
12+
minikube image build -t spring-client:1.0.0 .
13+
eval $(minikube docker-env)
14+
docker images
15+
- name: start spring-client using envoy
16+
shell: bash
17+
run: |
18+
kubectl label namespace default istio-injection=enabled
19+
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-client-sermant-xds-close.yaml
20+
kubectl wait --for=condition=ready pod -l app=spring-client --timeout=10s
21+
kubectl port-forward svc/spring-client 8080:8080 &
22+
kubectl label namespace default istio-injection-
23+
- name: Wait for spring-client pod to be ready
24+
shell: bash
25+
run: |
26+
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-server-sermant-xds-open.yaml
27+
kubectl wait --for=condition=ready pod -l app=spring-server --timeout=10s
28+
sleep 5s
29+
- name: test one server
30+
shell: bash
31+
run: |
32+
mvn test -Dxds.service.integration.test.type=DISCOVERY_ONE_SERVER_INSTANCE_ENVOY --file \
33+
sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml
34+
- name: stop spring-server
35+
shell: bash
36+
run: |
37+
kubectl delete -f sermant-integration-tests/xds-service-test/script/discovery/spring-server-sermant-xds-open.yaml
38+
sleep 3s
39+
- name: test the number of spring-server instances changes from 1 to 0
40+
shell: bash
41+
run: |
42+
mvn test -Dxds.service.integration.test.type=DISCOVERY_ZERO_SERVER_INSTANCE_ENVOY --file \
43+
sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml
44+
- name: restart spring-server
45+
shell: bash
46+
run: |
47+
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-server-sermant-xds-open.yaml
48+
kubectl wait --for=condition=ready pod -l app=spring-server --timeout=10s
49+
sleep 10s
50+
- name: test the number of spring-server instances changes from 0 to 1
51+
shell: bash
52+
run: |
53+
mvn test -Dxds.service.integration.test.type=DISCOVERY_ONE_SERVER_INSTANCE_ENVOY --file \
54+
sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml
55+
- name: close all service
56+
shell: bash
57+
run: |
58+
kubectl delete -f sermant-integration-tests/xds-service-test/script/discovery/spring-client-sermant-xds-close.yaml
59+
kubectl delete -f sermant-integration-tests/xds-service-test/script/discovery/spring-server-sermant-xds-open.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: "xDS Service Discovery Test"
2+
description: "Auto test for xds service discovery"
3+
runs:
4+
using: composite
5+
steps:
6+
- name: build docker image
7+
shell: bash
8+
run: |
9+
cd sermant-integration-tests/xds-service-test/product/spring-server/
10+
minikube image build -t spring-server:1.0.0 .
11+
cd ../spring-client/
12+
minikube image build -t spring-client:1.0.0 .
13+
eval $(minikube docker-env)
14+
docker images
15+
- name: start spring-client and spring-server
16+
shell: bash
17+
run: |
18+
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-client-sermant-xds-open.yaml
19+
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-server.yaml
20+
- name: Wait for spring-client pod to be ready
21+
shell: bash
22+
run: |
23+
kubectl wait --for=condition=ready pod -l app=spring-client --timeout=10s
24+
kubectl wait --for=condition=ready pod -l app=spring-server --timeout=10s
25+
kubectl port-forward svc/spring-client 8080:8080 &
26+
- name: test one server
27+
shell: bash
28+
run: |
29+
mvn test -Dxds.service.integration.test.type=DISCOVERY_ONE_SERVER_INSTANCE --file \
30+
sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml
31+
- name: stop spring-server
32+
shell: bash
33+
run: |
34+
kubectl delete -f sermant-integration-tests/xds-service-test/script/discovery/spring-server.yaml
35+
sleep 3s
36+
- name: test the number of spring-server instances changes from 1 to 0
37+
shell: bash
38+
run: |
39+
mvn test -Dxds.service.integration.test.type=DISCOVERY_ZERO_SERVER_INSTANCE --file \
40+
sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml
41+
- name: start spring-server with 2 replicas
42+
shell: bash
43+
run: |
44+
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-server-2-replicas.yaml
45+
kubectl wait --for=condition=ready pod -l app=spring-server --timeout=10s
46+
sleep 2s
47+
- name: test the number of spring-server instances changes from 0 to 2
48+
shell: bash
49+
run: |
50+
mvn test -Dxds.service.integration.test.type=DISCOVERY_TWO_SERVER_INSTANCE --file \
51+
sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml
52+
- name: create istio token
53+
shell: bash
54+
run: |
55+
kubectl create serviceaccount istio-test
56+
TOKEN=$(kubectl create token istio-test --duration=1h --audience=istio-ca)
57+
kubectl create secret generic istio-test-secret \
58+
--from-literal=token=${TOKEN} \
59+
--type="istio.io/key-and-cert" \
60+
-n default
61+
- name: restart spring-client and sermant xds service use security mode
62+
shell: bash
63+
run: |
64+
kubectl delete -f sermant-integration-tests/xds-service-test/script/discovery/spring-client-sermant-xds-open.yaml
65+
sleep 5s
66+
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-client-sermant-xds-subscribe-secure.yaml
67+
kubectl wait --for=condition=ready pod -l app=spring-client --timeout=10s
68+
pkill -f "kubectl port-forward svc/spring-client"
69+
kubectl port-forward svc/spring-client 8080:8080 &
70+
- name: test sermant xds service use security mode
71+
shell: bash
72+
run: |
73+
mvn test -Dxds.service.integration.test.type=SECRET --file \
74+
sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml
75+
- name: test subscribe to get service instance
76+
shell: bash
77+
run: |
78+
mvn test -Dxds.service.integration.test.type=DISCOVERY_SUBSCRIBE --file \
79+
sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml
80+
- name: close all service
81+
shell: bash
82+
run: |
83+
kubectl delete -f sermant-integration-tests/xds-service-test/script/discovery/spring-client-sermant-xds-subscribe-secure.yaml
84+
kubectl delete -f sermant-integration-tests/xds-service-test/script/discovery/spring-server-2-replicas.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: "xDS Service Discovery Test with Server Using Envoy"
2+
description: "Auto test for xds service discovery with server using envoy"
3+
runs:
4+
using: composite
5+
steps:
6+
- name: build docker image
7+
shell: bash
8+
run: |
9+
cd sermant-integration-tests/xds-service-test/product/spring-server/
10+
minikube image build -t spring-server:1.0.0 .
11+
cd ../spring-client/
12+
minikube image build -t spring-client:1.0.0 .
13+
eval $(minikube docker-env)
14+
docker images
15+
- name: start spring-client
16+
shell: bash
17+
run: |
18+
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-client-sermant-xds-open.yaml
19+
kubectl wait --for=condition=ready pod -l app=spring-client --timeout=10s
20+
kubectl port-forward svc/spring-client 8080:8080 &
21+
- name: start spring-server with envoy
22+
shell: bash
23+
run: |
24+
kubectl label namespace default istio-injection=enabled
25+
sleep 5s
26+
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-server.yaml
27+
kubectl wait --for=condition=ready pod -l app=spring-server --timeout=10s
28+
- name: test one server
29+
shell: bash
30+
run: |
31+
mvn test -Dxds.service.integration.test.type=DISCOVERY_ONE_SERVER_INSTANCE --file \
32+
sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml
33+
- name: stop spring-server
34+
shell: bash
35+
run: |
36+
kubectl delete -f sermant-integration-tests/xds-service-test/script/discovery/spring-server.yaml
37+
sleep 3s
38+
- name: test the number of spring-server instances changes from 1 to 0
39+
shell: bash
40+
run: |
41+
mvn test -Dxds.service.integration.test.type=DISCOVERY_ZERO_SERVER_INSTANCE --file \
42+
sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml
43+
- name: start spring-server with 2 replicas
44+
shell: bash
45+
run: |
46+
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-server-2-replicas.yaml
47+
kubectl wait --for=condition=ready pod -l app=spring-server --timeout=10s
48+
sleep 2s
49+
- name: test the number of spring-server instances changes from 0 to 2
50+
shell: bash
51+
run: |
52+
mvn test -Dxds.service.integration.test.type=DISCOVERY_TWO_SERVER_INSTANCE --file \
53+
sermant-integration-tests/xds-service-test/xds-service-integration-test/pom.xml
54+
- name: close all service
55+
shell: bash
56+
run: |
57+
kubectl delete -f sermant-integration-tests/xds-service-test/script/discovery/spring-client-sermant-xds-open.yaml
58+
kubectl delete -f sermant-integration-tests/xds-service-test/script/discovery/spring-server-2-replicas.yaml
+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: xds integration test
2+
on:
3+
push:
4+
pull_request:
5+
branches:
6+
- '*'
7+
paths:
8+
- 'sermant-agentcore/**'
9+
- 'sermant-integration-tests/xds-service-test/**'
10+
- '.github/workflows/xds_service_test.yml'
11+
- '.github/actions/common/xds-service/**'
12+
- '.github/actions/scenarios/xds-service/**'
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ github.head_ref }}
15+
cancel-in-progress: true
16+
jobs:
17+
build-agent-and-cache:
18+
name: build agent and cache
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
- name: Set up JDK 8
23+
uses: actions/setup-java@v3
24+
with:
25+
java-version: '8'
26+
distribution: 'adopt'
27+
cache: maven
28+
- name: cache agent
29+
uses: actions/cache@v3
30+
with:
31+
path: sermant-agent-*/
32+
key: ${{ runner.os }}-agent-${{ github.run_id }}
33+
- name: cache xds service package
34+
uses: actions/cache@v3
35+
with:
36+
path: sermant-integration-tests/xds-service-test/product/
37+
key: ${{ runner.os }}-xds-service-product-${{ github.run_id }}
38+
- name: package agent
39+
run: |
40+
sed -i '/sermant-backend/d' pom.xml
41+
sed -i '/sermant-injector/d' pom.xml
42+
mvn package -DskipTests -Ptest --file pom.xml
43+
cp -r sermant-integration-tests/xds-service-test/product/spring-client/agent sermant-integration-tests/xds-service-test/product/spring-server/
44+
test-for-xds-service-discovery-onlysermant:
45+
name: Test for xds service discovery with only sermant
46+
runs-on: ubuntu-latest
47+
needs: [build-agent-and-cache]
48+
steps:
49+
- uses: actions/checkout@v3
50+
with:
51+
fetch-depth: 100
52+
- name: set java version to environment
53+
run: |
54+
echo "javaVersion=8" >> $GITHUB_ENV
55+
- name: xds common operation
56+
uses: ./.github/actions/common/xds-service
57+
- name: xds service discovery
58+
uses: ./.github/actions/scenarios/xds-service/xds-service-discovery/sermant-only
59+
test-for-xds-service-discovery-with-server-envoy:
60+
name: Test for xds service discovery with spring-server using envoy
61+
runs-on: ubuntu-latest
62+
needs: [build-agent-and-cache]
63+
steps:
64+
- uses: actions/checkout@v3
65+
with:
66+
fetch-depth: 100
67+
- name: set java version to environment
68+
run: |
69+
echo "javaVersion=8" >> $GITHUB_ENV
70+
- name: xds common operation
71+
uses: ./.github/actions/common/xds-service
72+
- name: xds service discovery
73+
uses: ./.github/actions/scenarios/xds-service/xds-service-discovery/server-envoy
74+
test-for-xds-service-discovery-with-client-envoy:
75+
name: Test for xds service discovery with spring-client using enovy
76+
runs-on: ubuntu-latest
77+
needs: [build-agent-and-cache]
78+
steps:
79+
- uses: actions/checkout@v3
80+
with:
81+
fetch-depth: 100
82+
- name: set java version to environment
83+
run: |
84+
echo "javaVersion=8" >> $GITHUB_ENV
85+
- name: xds common operation
86+
uses: ./.github/actions/common/xds-service
87+
- name: xds service discovery
88+
uses: ./.github/actions/scenarios/xds-service/xds-service-discovery/client-envoy

sermant-agentcore/sermant-agentcore-config/config/test/config.properties

+9
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ agent.service.inject.enable=true
3434
agent.service.dynamic.config.enable=true
3535
# HTTP server switch
3636
agent.service.httpserver.enable=false
37+
# xDS service switch
38+
agent.service.xds.service.enable=false
3739
#============================= Event configuration =============================#
3840
# Event switch
3941
event.enable=false
@@ -91,6 +93,13 @@ gateway.nettyPort=6888
9193
#gateway.initReconnectInternalTime=5
9294
# Specify retreat algorithm maximum connection interval (s)
9395
#gateway.maxReconnectInternalTime=180
96+
#=============================xds configuration===============================#
97+
# istiod control plane address, security.enable=false with 15010 port, and security.enable=true with 15012 port
98+
xds.config.control.plane.address=istiod.istio-system.svc:15010
99+
# Whether to use secure communication with the control plane
100+
xds.config.security.enable=false
101+
# service account token used for secure communication with the control plane
102+
xds.config.service.account.token.path=/var/run/secrets/kubernetes.io/serviceaccount/token
94103
#=============================Metadata===============================#
95104
# Service name for host service instance
96105
service.meta.service=default

sermant-integration-tests/pom.xml

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!--
3-
~ Copyright (C) 2022-2022 Huawei Technologies Co., Ltd. All rights reserved.
4-
~
5-
~ Licensed under the Apache License, Version 2.0 (the "License");
6-
~ you may not use this file except in compliance with the License.
7-
~ You may obtain a copy of the License at
8-
~
9-
~ http://www.apache.org/licenses/LICENSE-2.0
10-
~
11-
~ Unless required by applicable law or agreed to in writing, software
12-
~ distributed under the License is distributed on an "AS IS" BASIS,
13-
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
~ See the License for the specific language governing permissions and
15-
~ limitations under the License.
16-
-->
172
<project xmlns="http://maven.apache.org/POM/4.0.0"
183
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
194
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -35,5 +20,6 @@
3520
<module>tag-transmission-test</module>
3621
<module>mq-consume-prohibition-test</module>
3722
<module>database-write-prohibition-test</module>
23+
<module>xds-service-test</module>
3824
</modules>
3925
</project>

0 commit comments

Comments
 (0)