Skip to content

Commit 00d7c9f

Browse files
committed
[occm] Use CI job cloud-provider-openstack-test-occm
1 parent d6c6447 commit 00d7c9f

File tree

2 files changed

+15
-49
lines changed

2 files changed

+15
-49
lines changed

.zuul.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99
- ^SECURITY_CONTACTS$
1010
- ^.gitignore$
1111
- ^.*\.sh$
12-
cloud-provider-openstack-acceptance-test-lb-octavia:
12+
cloud-provider-openstack-test-occm:
1313
jobs:
14-
- cloud-provider-openstack-acceptance-test-lb-octavia:
14+
- cloud-provider-openstack-test-occm:
1515
files:
1616
- cmd/openstack-cloud-controller-manager/.*
1717
- pkg/openstack/.*
1818
- pkg/util/.*
1919
- tests/e2e/cloudprovider/.*
20-
- go.mod$
21-
- go.sum$
2220
- Makefile$
2321
irrelevant-files:
2422
- docs/.*$

tests/e2e/cloudprovider/test-lb-service.sh

Lines changed: 13 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
#!/usr/bin/env bash
22

3-
# This script is used for the openlab CI job cloud-provider-openstack-acceptance-test-lb-octavia.
4-
# See https://github.com/theopenlab/openlab-zuul-jobs/blob/master/playbooks/cloud-provider-openstack-acceptance-test-lb-octavia/run.yaml#L104
3+
# This script is used for the openlab CI job cloud-provider-openstack-test-occm.
54
#
65
# Prerequisites:
7-
# - This script is supposed to be running on a host has access to kubernetes cluster.
6+
# - This script is supposed to be running on the CI host which is running devstack.
87
# - kubectl is ready to talk with the kubernetes cluster.
9-
# - It's recommended to run the script on a host with as less proxies to the public as possible, otherwise the
10-
# x-forwarded-for test will probably fail.
118
# - This script is not responsible for resource clean up if there is test case fails.
129
set -x
1310

1411
TIMEOUT=${TIMEOUT:-300}
1512
FLOATING_IP=${FLOATING_IP:-""}
1613
NAMESPACE="octavia-lb-test"
14+
GATEWAY_IP=${GATEWAY_IP:-""}
15+
OS_RC=${OS_RC:-"/home/zuul/devstack/openrc"}
1716

1817
delete_resources() {
1918
ERROR_CODE="$?"
@@ -63,7 +62,7 @@ function wait_for_loadbalancer {
6362

6463
end=$(($(date +%s) + ${TIMEOUT}))
6564
while true; do
66-
status=$(kubectl -n $NAMESPACE exec openstackcli -- openstack loadbalancer show $lbid -f value -c provisioning_status)
65+
status=$(openstack loadbalancer show $lbid -f value -c provisioning_status)
6766
if [[ $status == "ACTIVE" ]]; then
6867
if [[ $i == 2 ]]; then
6968
printf "\n>>>>>>> Load balancer ${lbid} is ACTIVE\n"
@@ -152,37 +151,6 @@ spec:
152151
EOF
153152
}
154153

155-
########################################################################
156-
## Name: create_openstackcli_pod
157-
## Desc: Makes sure the openstackcli pod is running.
158-
## Params: None
159-
########################################################################
160-
function create_openstackcli_pod {
161-
kubectl -n $NAMESPACE get pod | grep openstackcli | grep Running > /dev/null
162-
if [[ $? -eq 1 ]]; then
163-
printf "\n>>>>>>> Creating openstackcli pod\n"
164-
cat <<EOF | kubectl apply -f -
165-
apiVersion: v1
166-
kind: Pod
167-
metadata:
168-
name: openstackcli
169-
namespace: $NAMESPACE
170-
spec:
171-
containers:
172-
- name: openstackcli
173-
image: lingxiankong/openstack-cli:1.0.0
174-
envFrom:
175-
- secretRef:
176-
name: openrc
177-
command:
178-
- sleep
179-
- "3600"
180-
EOF
181-
kubectl -n $NAMESPACE wait --for=condition=Ready pod/openstackcli
182-
printf "\n>>>>>>> Pod openstackcli created.\n"
183-
fi
184-
}
185-
186154
########################################################################
187155
## Name: test_basic
188156
## Desc: Create a k8s service and send request to the service external
@@ -260,9 +228,9 @@ EOF
260228
wait_for_service ${service}
261229

262230
printf "\n>>>>>>> Sending request to the Service ${service}\n"
263-
orig_ip=$(curl -s http://${ipaddr} | grep x-forwarded-for | awk -F'=' '{print $2}')
264-
if [[ "${orig_ip}" != "${local_ip}" && "${orig_ip}" != "${public_ip}" ]]; then
265-
printf "\n>>>>>>> FAIL: Get incorrect response from Service ${service}, orig_ip: ${local_ip}, public_ip: ${public_ip}\n"
231+
ip_in_header=$(curl -s http://${ipaddr} | grep x-forwarded-for | awk -F'=' '{print $2}')
232+
if [[ "${ip_in_header}" != "${local_ip}" && "${ip_in_header}" != "${public_ip}" && "${ip_in_header}" != "${GATEWAY_IP}" ]]; then
233+
printf "\n>>>>>>> FAIL: Get incorrect response from Service ${service}, ip_in_header: ${ip_in_header}, local_ip: ${local_ip}, gateway_ip: ${GATEWAY_IP}, public_ip: ${public_ip}\n"
266234
exit -1
267235
else
268236
printf "\n>>>>>>> Expected: Get correct response from Service ${service}\n"
@@ -308,12 +276,12 @@ EOF
308276
wait_for_service ${service}
309277

310278
printf "\n>>>>>>> Validating openstack load balancer\n"
311-
create_openstackcli_pod
312-
lbid=$(kubectl -n $NAMESPACE exec openstackcli -- openstack loadbalancer list -c id -c name | grep "octavia-lb-test_${service}" | awk '{print $2}')
313-
lb_info=$(kubectl -n $NAMESPACE exec openstackcli -- openstack loadbalancer status show $lbid)
279+
set +x; source $OS_RC demo demo; set -x
280+
lbid=$(openstack loadbalancer list -c id -c name | grep "octavia-lb-test_${service}" | awk '{print $2}')
281+
lb_info=$(openstack loadbalancer status show $lbid)
314282
listener_count=$(echo $lb_info | jq '.loadbalancer.listeners | length')
315283
member_ports=$(echo $lb_info | jq '.loadbalancer.listeners | .[].pools | .[].members | .[].protocol_port' | uniq)
316-
service_nodeports=$(kubectl -n $NAMESPACE get svc $service -o json | jq '.spec.ports | .[].nodePort')
284+
service_nodeports=$(kubectl -n $NAMESPACE get svc $service -o json | jq '.spec.ports | .[].nodePort')
317285

318286
if [[ ${listener_count} != 2 ]]; then
319287
printf "\n>>>>>>> FAIL: Unexpected number of listeners(${listener_count}) created for service ${service}\n"
@@ -334,7 +302,7 @@ EOF
334302

335303
printf "\n>>>>>>> Validating openstack load balancer after updating the service.\n"
336304
create_openstackcli_pod
337-
lb_info=$(kubectl -n $NAMESPACE exec openstackcli -- openstack loadbalancer status show $lbid)
305+
lb_info=$(openstack loadbalancer status show $lbid)
338306
listener_count=$(echo $lb_info | jq '.loadbalancer.listeners | length')
339307
member_port=$(echo $lb_info | jq '.loadbalancer.listeners | .[].pools | .[].members | .[].protocol_port' | uniq)
340308
service_nodeport=$(kubectl -n $NAMESPACE get svc $service -o json | jq '.spec.ports | .[].nodePort')

0 commit comments

Comments
 (0)