Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add service status check to optimize xds integration test #1594

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,27 @@ runs:
minikube image build -t spring-client:1.0.0 .
eval $(minikube docker-env)
docker images
- name: start spring-client using envoy
- name: start spring-client using envoy and wait
shell: bash
run: |
kubectl label namespace default istio-injection=enabled
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-client-sermant-xds-close.yaml
kubectl wait --for=condition=ready pod -l app=spring-client --timeout=10s
kubectl port-forward svc/spring-client 8080:8080 &
sleep 10s
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
kubectl label namespace default istio-injection-
- name: Wait for spring-client pod to be ready
- name: start spring-server and wait
shell: bash
run: |
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-server-sermant-xds-open.yaml
kubectl wait --for=condition=ready pod -l app=spring-server --timeout=10s
sleep 10s
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: test one server
shell: bash
run: |
Expand All @@ -47,6 +54,10 @@ runs:
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-server-sermant-xds-open.yaml
kubectl wait --for=condition=ready pod -l app=spring-server --timeout=10s
sleep 10s
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: test the number of spring-server instances changes from 0 to 1
shell: bash
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ runs:
run: |
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-client-sermant-xds-open.yaml
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-server.yaml
- name: Wait for spring-client pod to be ready
- name: Wait for spring-client pod and spring-server pod to be ready
shell: bash
run: |
kubectl wait --for=condition=ready pod -l app=spring-client --timeout=10s
kubectl wait --for=condition=ready pod -l app=spring-server --timeout=10s
kubectl port-forward svc/spring-client 8080:8080 &
sleep 10s
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
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: test one server
shell: bash
run: |
Expand All @@ -45,6 +51,10 @@ runs:
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-server-2-replicas.yaml
kubectl wait --for=condition=ready pod -l app=spring-server --timeout=10s
sleep 10s
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: test the number of spring-server instances changes from 0 to 2
shell: bash
run: |
Expand All @@ -66,9 +76,11 @@ runs:
sleep 10s
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-client-sermant-xds-subscribe-secure.yaml
kubectl wait --for=condition=ready pod -l app=spring-client --timeout=10s
pkill -f "kubectl port-forward svc/spring-client"
kubectl port-forward svc/spring-client 8080:8080 &
sleep 10s
pkill -f "kubectl port-forward svc/spring-client"
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: test sermant xds service use security mode
shell: bash
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ runs:
run: |
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-client-sermant-xds-open.yaml
kubectl wait --for=condition=ready pod -l app=spring-client --timeout=10s
kubectl port-forward svc/spring-client 8080:8080 &
sleep 10s
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-server with envoy
shell: bash
run: |
Expand All @@ -26,6 +29,10 @@ runs:
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-server.yaml
kubectl wait --for=condition=ready pod -l app=spring-server --timeout=10s
sleep 10s
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: test one server
shell: bash
run: |
Expand All @@ -47,6 +54,10 @@ runs:
kubectl apply -f sermant-integration-tests/xds-service-test/script/discovery/spring-server-2-replicas.yaml
kubectl wait --for=condition=ready pod -l app=spring-server --timeout=10s
sleep 10s
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: test the number of spring-server instances changes from 0 to 2
shell: bash
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
image: spring-server:1.0.0
imagePullPolicy: Never
ports:
- containerPort: 8080
- containerPort: 8081
imagePullSecrets:
- name: default-secret
---
Expand All @@ -28,8 +28,8 @@ metadata:
spec:
type: ClusterIP
ports:
- port: 8080
targetPort: 8080
- port: 8081
targetPort: 8081
protocol: TCP
name: http
selector:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
image: spring-server:1.0.0
imagePullPolicy: Never
ports:
- containerPort: 8080
- containerPort: 8081
env:
- name: JAVA_TOOL_OPTIONS
value: "-javaagent:/home/agent/sermant-agent.jar"
Expand All @@ -31,8 +31,8 @@ metadata:
spec:
type: ClusterIP
ports:
- port: 8080
targetPort: 8080
- port: 8081
targetPort: 8081
protocol: TCP
name: http
selector:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
image: spring-server:1.0.0
imagePullPolicy: Never
ports:
- containerPort: 8080
- containerPort: 8081
imagePullSecrets:
- name: default-secret
---
Expand All @@ -28,8 +28,8 @@ metadata:
spec:
type: ClusterIP
ports:
- port: 8080
targetPort: 8080
- port: 8081
targetPort: 8081
protocol: TCP
name: http
selector:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ public String hello(String address) {
return httpGet(urlBuilder.toString());
}

/**
* check service status
*
* @return result
*/
@RequestMapping("checkStatus")
public String checkStatus() {
return "ok";
}

private String httpGet(String url) {
HttpGet httpGet = new HttpGet(url);
try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
server.port=8081
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void testDiscoveryWithSubscribe() {
"DISCOVERY_ONE_SERVER_INSTANCE_ENVOY")
public void testDiscoveryWithClientUsingEnvoyAndOneInstance() {
Assertions.assertEquals("hello", HttpRequestUtils.doGet("http://127.0.0.1:8080/hello?address=spring-server"
+ ".default.svc.cluster.local:8080"));
+ ".default.svc.cluster.local:8081"));
}

/**
Expand All @@ -107,7 +107,7 @@ public void testDiscoveryWithClientUsingEnvoyAndOneInstance() {
"DISCOVERY_ZERO_SERVER_INSTANCE_ENVOY")
public void testDiscoveryWithClientUsingEnvoyAndZeroInstance() {
Assertions.assertEquals("", HttpRequestUtils.doGet("http://127.0.0.1:8080/hello?address=spring-server"
+ ".default.svc.cluster.local:8080"));
+ ".default.svc.cluster.local:8081"));
}

private String[] splitResult(String result) {
Expand Down
Loading