From 19804048ebf208e83265270ce6b9b515951f7f39 Mon Sep 17 00:00:00 2001 From: Michal Nasiadka Date: Fri, 19 Jul 2024 14:32:52 +0200 Subject: [PATCH] CI: Fix cases where port is not available yet Closes-Bug: #2075966 Change-Id: I6ed82ecc7ca82c09aacb2a65254f794c72365188 --- tests/test-core-openstack.sh | 11 +++++++++++ tests/test-magnum.sh | 11 +++++++++++ tests/test-octavia.sh | 22 ++++++++++++++++++++++ tests/test-ovn.sh | 11 +++++++++++ 4 files changed, 55 insertions(+) diff --git a/tests/test-core-openstack.sh b/tests/test-core-openstack.sh index 0bf4acef7e..59b219cb27 100755 --- a/tests/test-core-openstack.sh +++ b/tests/test-core-openstack.sh @@ -441,6 +441,17 @@ function test_internal_dns_integration { openstack server create --image cirros --flavor m1.tiny --network dns-test-network ${SERVER_NAME} SERVER_ID=$(openstack server show ${SERVER_NAME} -f value -c id) + attempt=0 + while [[ -z $(openstack port list --device-id ${SERVER_ID} -f value -c ID) ]]; do + echo "Port for server ${SERVER_NAME} not available yet" + attempt=$((attempt+1)) + if [[ $attempt -eq 10 ]]; then + echo "ERROR: Port for server ${SERVER_NAME} failed to become available" + openstack port list --device-id ${SERVER_ID} + return 1 + fi + sleep $attempt + done PORT_ID=$(openstack port list --device-id ${SERVER_ID} -f value -c ID) DNS_ASSIGNMENT=$(openstack port show ${PORT_ID} -f json -c dns_assignment) diff --git a/tests/test-magnum.sh b/tests/test-magnum.sh index df4352c12c..6d580a856a 100755 --- a/tests/test-magnum.sh +++ b/tests/test-magnum.sh @@ -61,6 +61,17 @@ function test_designate { openstack server create --image cirros --flavor m1.tiny --network tenant-dns-test ${SERVER_NAME} SERVER_ID=$(openstack server show ${SERVER_NAME} -f value -c id) + attempt=0 + while [[ -z $(openstack port list --device-id ${SERVER_ID} -f value -c ID) ]]; do + echo "Port for server ${SERVER_NAME} not available yet" + attempt=$((attempt+1)) + if [[ $attempt -eq 10 ]]; then + echo "ERROR: Port for server ${SERVER_NAME} failed to become available" + openstack port list --device-id ${SERVER_ID} + return 1 + fi + sleep $attempt + done PORT_ID=$(openstack port list --device-id ${SERVER_ID} -f value -c ID) openstack floating ip create public1 --port ${PORT_ID} diff --git a/tests/test-octavia.sh b/tests/test-octavia.sh index cc033ac5a7..032230bbe7 100644 --- a/tests/test-octavia.sh +++ b/tests/test-octavia.sh @@ -58,6 +58,17 @@ function test_octavia { # Add a floating IP to the load balancer. lb_fip=$(openstack floating ip create public1 -f value -c name) lb_vip=$(openstack loadbalancer show lb -f value -c vip_address) + attempt=0 + while [[ $(openstack port list --fixed-ip ip-address=$lb_vip -f value -c ID) == "" ]]; do + echo "Port for LB with VIP ip addr $lb_vip not available yet" + attempt=$((attempt+1)) + if [[ $attempt -eq 10 ]]; then + echo "ERROR: Port for LB with VIP ip addr failed to become available" + openstack port list --fixed-ip ip-address=$lb_vip + return 1 + fi + sleep $attempt + done lb_port_id=$(openstack port list --fixed-ip ip-address=$lb_vip -f value -c ID) openstack floating ip set $lb_fip --port $lb_port_id @@ -124,6 +135,17 @@ function test_internal_dns_integration { openstack server create --image cirros --flavor m1.tiny --network dns-test-network ${SERVER_NAME} SERVER_ID=$(openstack server show ${SERVER_NAME} -f value -c id) + attempt=0 + while [[ $(openstack port list --device-id ${SERVER_ID} -f value -c ID) == "" ]]; do + echo "Port for server ${SERVER_NAME} not available yet" + attempt=$((attempt+1)) + if [[ $attempt -eq 10 ]]; then + echo "ERROR: Port for server ${SERVER_NAME} failed to become available" + openstack port list --device-id ${SERVER_ID} + return 1 + fi + sleep $attempt + done PORT_ID=$(openstack port list --device-id ${SERVER_ID} -f value -c ID) DNS_ASSIGNMENT=$(openstack port show ${PORT_ID} -f json -c dns_assignment) diff --git a/tests/test-ovn.sh b/tests/test-ovn.sh index 307105c3c0..f7aa74e688 100755 --- a/tests/test-ovn.sh +++ b/tests/test-ovn.sh @@ -74,6 +74,17 @@ function test_octavia { echo "Add a floating IP to the load balancer." lb_fip=$(openstack floating ip create public1 -f value -c name) lb_vip=$(openstack loadbalancer show test_ovn_lb -f value -c vip_address) + attempt=0 + while [[ $(openstack port list --fixed-ip ip-address=$lb_vip -f value -c ID) == "" ]]; do + echo "Port for LB with VIP ip addr $lb_vip not available yet" + attempt=$((attempt+1)) + if [[ $attempt -eq 10 ]]; then + echo "ERROR: Port for LB with VIP ip addr failed to become available" + openstack port list --fixed-ip ip-address=$lb_vip + return 1 + fi + sleep $attempt + done lb_port_id=$(openstack port list --fixed-ip ip-address=$lb_vip -f value -c ID) openstack floating ip set $lb_fip --port $lb_port_id