From 1a4689975eebc7247a1c15ff5d7514dbc21109fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= <radoslaw.piliszek@gmail.com>
Date: Mon, 3 Oct 2022 16:49:27 +0200
Subject: [PATCH] [CI] Test image from instance

This is a missing Nova->Glance interaction that is sometimes
useful.

Change-Id: I05b22d90ec31ef3b63210c2563d6e5547d565874
Depends-On: https://review.opendev.org/c/openstack/kolla/+/860230
---
 tests/test-core-openstack.sh | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tests/test-core-openstack.sh b/tests/test-core-openstack.sh
index 96ad7dd7a3..2f32ddf235 100755
--- a/tests/test-core-openstack.sh
+++ b/tests/test-core-openstack.sh
@@ -77,6 +77,26 @@ function create_an_image_from_volume {
     done
 }
 
+function create_an_image_from_instance {
+    local image_name=$1
+    local instance_name=$2
+
+    local attempt
+
+    openstack server image create $instance_name --name $image_name
+    attempt=1
+    while [[ $(openstack image show $image_name -f value -c status) != "active" ]]; do
+        echo "Image $image_name not active yet"
+        attempt=$((attempt+1))
+        if [[ $attempt -eq 11 ]]; then
+            echo "Image $image_name failed to become active"
+            openstack image show $image_name
+            return 1
+        fi
+        sleep 30
+    done
+}
+
 function attach_and_detach_a_volume {
     local volume_name=$1
     local instance_name=$2
@@ -259,6 +279,11 @@ function test_instance_boot {
         echo "SUCCESS: Glance image from Cinder volume and back to volume"
     fi
 
+    echo "TESTING: Instance image upload"
+    create_an_image_from_instance image_from_instance kolla_boot_test
+    openstack image delete image_from_instance
+    echo "SUCCESS: Instance image upload"
+
     echo "TESTING: Floating ip allocation"
     fip_addr=$(create_fip)
     attach_fip kolla_boot_test ${fip_addr}