From e32715b2515fdae523a3d113a881f0a57fff9410 Mon Sep 17 00:00:00 2001 From: Ghanshyam Mann Date: Thu, 22 Jun 2023 21:10:31 -0500 Subject: [PATCH] Set two different image in tempest irespective of DEFAULT_IMAGE_NAME In current logic to set two different image in Tempest in config option image_ref and image_ref_alt, we consider if DEFAULT_IMAGE_NAME is found in glance then set the same image in tempest for those two config option. This means even we have two different image available in glance, still we set same image in image_ref as well as image_ref_alt and all the rebuild tests are rebuilt on the same image. I could not find any reason why we set same image if DEFAULT_IMAGE_NAME exist, below are the original change added this logic - https://review.opendev.org/c/openstack/devstack/+/17553 We had a requirement of test to run on two different images - https://review.opendev.org/c/openstack/tempest/+/831018 and for that we need to set DEFAULT_IMAGE_NAME to non exist image name but that broke the Ironic which was reply on the valid name in DEFAULT_IMAGE_NAME - https://review.opendev.org/c/openstack/ironic/+/886790 As we do not have any reason not to set two different image if DEFAULT_IMAGE_NAME is set, I am removing the condition of DEFAULT_IMAGE_NAME from lib/tempest logic and always set two different images if they are available. Depends-On: https://review.opendev.org/c/openstack/tempest/+/886796 Change-Id: I9d215f48d4440f2fa6dcc0d222a10896caf01215 --- lib/tempest | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/tempest b/lib/tempest index 9fa989a2f6..4f72a6d174 100644 --- a/lib/tempest +++ b/lib/tempest @@ -149,11 +149,10 @@ function set_tempest_venv_constraints { # ramdisk and kernel images. Takes 3 arguments, an array and two # variables. The array will contain the list of active image UUIDs; # if an image with ``DEFAULT_IMAGE_NAME`` is found, its UUID will be -# set as the value of *both* other parameters. +# set as the value img_id ($2) parameters. function get_active_images { declare -n img_array=$1 declare -n img_id=$2 - declare -n img_id_alt=$3 # start with a fresh array in case we are called multiple times img_array=() @@ -161,7 +160,6 @@ function get_active_images { while read -r IMAGE_NAME IMAGE_UUID; do if [ "$IMAGE_NAME" = "$DEFAULT_IMAGE_NAME" ]; then img_id="$IMAGE_UUID" - img_id_alt="$IMAGE_UUID" fi img_array+=($IMAGE_UUID) done < <(openstack --os-cloud devstack-admin image list --property status=active | awk -F'|' '!/^(+--)|ID|aki|ari/ { print $3,$2 }') @@ -170,13 +168,12 @@ function get_active_images { function poll_glance_images { declare -n image_array=$1 declare -n image_id=$2 - declare -n image_id_alt=$3 local -i poll_count poll_count=$TEMPEST_GLANCE_IMPORT_POLL_LIMIT while (( poll_count-- > 0 )) ; do sleep $TEMPEST_GLANCE_IMPORT_POLL_INTERVAL - get_active_images image_array image_id image_id_alt + get_active_images image_array image_id if (( ${#image_array[*]} >= $TEMPEST_GLANCE_IMAGE_COUNT )) ; then return fi @@ -228,7 +225,7 @@ function configure_tempest { declare -a images if is_service_enabled glance; then - get_active_images images image_uuid image_uuid_alt + get_active_images images image_uuid if (( ${#images[*]} < $TEMPEST_GLANCE_IMAGE_COUNT )); then # Glance image import is asynchronous and may be configured @@ -236,7 +233,7 @@ function configure_tempest { # it's possible that this code is being executed before the # import has completed and there may be no active images yet. if [[ "$GLANCE_USE_IMPORT_WORKFLOW" == "True" ]]; then - poll_glance_images images image_uuid image_uuid_alt + poll_glance_images images image_uuid if (( ${#images[*]} < $TEMPEST_GLANCE_IMAGE_COUNT )); then echo "Only found ${#images[*]} image(s), was looking for $TEMPEST_GLANCE_IMAGE_COUNT" exit 1 @@ -258,7 +255,15 @@ function configure_tempest { *) if [ -z "$image_uuid" ]; then image_uuid=${images[0]} - image_uuid_alt=${images[1]} + if [ -z "$image_uuid_alt" ]; then + image_uuid_alt=${images[1]} + fi + elif [ -z "$image_uuid_alt" ]; then + for image in $images; do + if [[ "$image" != "$image_uuid" ]]; then + image_uuid_alt=$image + fi + done fi ;; esac