From ea014b203c597151ba071248af80cb3a2048de89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= Date: Sun, 17 Oct 2021 19:57:57 +0000 Subject: [PATCH] [CI] Test that Cinder can create volume from image To catch early issues like [1]. [1] https://bugs.launchpad.net/cinder/+bug/1947518 Change-Id: I8091817939b976fbd5e44a9640b573cc112a0525 --- tests/test-core-openstack.sh | 39 ++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/tests/test-core-openstack.sh b/tests/test-core-openstack.sh index de978485ed..a20e2d00d1 100755 --- a/tests/test-core-openstack.sh +++ b/tests/test-core-openstack.sh @@ -35,6 +35,26 @@ function create_a_volume { done } +function create_a_volume_from_image { + local volume_name=$1 + local image_name=$2 + + local attempt + + openstack volume create --image $image_name --size 2 $volume_name + attempt=1 + while [[ $(openstack volume show $volume_name -f value -c status) != "available" ]]; do + echo "Volume $volume_name not available yet" + attempt=$((attempt+1)) + if [[ $attempt -eq 10 ]]; then + echo "Volume $volume_name failed to become available" + openstack volume show $volume_name + return 1 + fi + sleep 10 + done +} + function attach_and_detach_a_volume { local volume_name=$1 local instance_name=$2 @@ -161,14 +181,29 @@ function test_instance_boot { echo "SUCCESS: Server creation" if [[ $SCENARIO == "cephadm" ]] || [[ $SCENARIO == "zun" ]]; then - echo "TESTING: Cinder volume attachment" + echo "TESTING: Cinder volume creation and attachment" create_a_volume test_volume openstack volume show test_volume attach_and_detach_a_volume test_volume kolla_boot_test delete_a_volume test_volume - echo "SUCCESS: Cinder volume attachment" + # test a qcow2 image (non-cloneable) + create_a_volume_from_image test_volume_from_image cirros + openstack volume show test_volume_from_image + attach_and_detach_a_volume test_volume_from_image kolla_boot_test + delete_a_volume test_volume_from_image + + # test a raw image (cloneable) + openstack image create --disk-format raw --container-format bare --public \ + --file /etc/passwd raw-image + create_a_volume_from_image test_volume_from_image raw-image + openstack volume show test_volume_from_image + attach_and_detach_a_volume test_volume_from_image kolla_boot_test + delete_a_volume test_volume_from_image + openstack image delete raw-image + + echo "SUCCESS: Cinder volume creation and attachment" if [[ $HAS_UPGRADE == 'yes' ]]; then echo "TESTING: Cinder volume upgrade stability (PHASE: $PHASE)"