From 6688347857e3b6e22b02df82d39c89591541c9d1 Mon Sep 17 00:00:00 2001 From: Pierre Riteau Date: Fri, 5 Jan 2024 13:09:51 +0100 Subject: [PATCH] CI: Test Nova server resize functionality This adds an extra resize operation to core OpenStack tests. This should be fast since we are only increasing the number of cores of the VM and could help catch additional errors in CI tests. Change-Id: Ia61b995dbffcda4f1e6494548df457231cb67bd7 (cherry picked from commit f86ed0270f74270dd4552ea064f8de4df9fe0758) --- tests/test-core-openstack.sh | 38 ++++++++++++++++++++++++++++++++++++ tools/init-runonce | 1 + 2 files changed, 39 insertions(+) diff --git a/tests/test-core-openstack.sh b/tests/test-core-openstack.sh index 4f27db39a1..04fac850c5 100755 --- a/tests/test-core-openstack.sh +++ b/tests/test-core-openstack.sh @@ -168,6 +168,40 @@ function create_instance { fi } +function resize_instance { + local name=$1 + + # TODO(priteau): Remove once previous_release includes m2.tiny in + # init-runonce + if ! openstack flavor list -f value | grep m2.tiny; then + openstack flavor create --id 6 --ram 512 --disk 1 --vcpus 2 m2.tiny + fi + + openstack server resize --flavor m2.tiny --wait ${name} + # If the status is not VERIFY_RESIZE, print info and exit 1 + if [[ $(openstack server show ${name} -f value -c status) != "VERIFY_RESIZE" ]]; then + echo "FAILED: Instance is not resized" + openstack --debug server show ${name} + return 1 + fi + + openstack server resize confirm ${name} + + # Confirming the resize operation is not instantaneous. Wait for change to + # be reflected in server status. + attempt=1 + while [[ $(openstack server show ${name} -f value -c status) != "ACTIVE" ]]; do + echo "Instance is not active yet" + attempt=$((attempt+1)) + if [[ $attempt -eq 5 ]]; then + echo "FAILED: Instance failed to become active after resize confirm" + openstack --debug server show ${name} + return 1 + fi + sleep 1 + done +} + function delete_instance { local name=$1 openstack server delete --wait ${name} @@ -329,6 +363,10 @@ function test_instance_boot { delete_fip ${fip_addr} echo "SUCCESS: Floating ip deallocation" + echo "TESTING: Server resize" + resize_instance kolla_boot_test + echo "SUCCESS: Server resize" + echo "TESTING: Server deletion" delete_instance kolla_boot_test echo "SUCCESS: Server deletion" diff --git a/tools/init-runonce b/tools/init-runonce index e3336a43d3..09e99b92e5 100755 --- a/tools/init-runonce +++ b/tools/init-runonce @@ -146,6 +146,7 @@ if ! $KOLLA_OPENSTACK_COMMAND flavor list | grep -q m1.tiny; then $KOLLA_OPENSTACK_COMMAND flavor create --id 3 --ram 4096 --disk 40 --vcpus 2 m1.medium $KOLLA_OPENSTACK_COMMAND flavor create --id 4 --ram 8192 --disk 80 --vcpus 4 m1.large $KOLLA_OPENSTACK_COMMAND flavor create --id 5 --ram 16384 --disk 160 --vcpus 8 m1.xlarge + $KOLLA_OPENSTACK_COMMAND flavor create --id 6 --ram 512 --disk 1 --vcpus 2 m2.tiny fi cat << EOF