Skip to content

Commit f97e752

Browse files
committed
[CI] Cinder upgrade testing
To gain visibility into how our upgrades affect existing Cinder volumes, a new testing path is required. This patch adds it. Additionally, it refactors the repeated actions and ensures that we wait for volume deletions as well. Change-Id: Ic08d461e6fdf91c378a87860765a489c2f86d690 Related-Bug: #1904062 (cherry picked from commit 62b8c6b)
1 parent e2fac22 commit f97e752

File tree

2 files changed

+104
-37
lines changed

2 files changed

+104
-37
lines changed

tests/run.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,8 @@
397397
chdir: "{{ kolla_ansible_src_dir }}"
398398
environment:
399399
SCENARIO: "{{ scenario }}"
400+
HAS_UPGRADE: "{{ is_upgrade | bool | ternary('yes', 'no') }}"
401+
PHASE: deploy
400402
when: openstack_core_tested
401403

402404
- name: Run test-zun.sh script
@@ -588,6 +590,8 @@
588590
chdir: "{{ kolla_ansible_src_dir }}"
589591
environment:
590592
SCENARIO: "{{ scenario }}"
593+
HAS_UPGRADE: 'yes'
594+
PHASE: upgrade
591595
when: openstack_core_tested
592596
when: is_upgrade
593597

tests/test-core-openstack.sh

Lines changed: 100 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,85 @@ function test_smoke {
1616
fi
1717
}
1818

19+
function create_a_volume {
20+
local volume_name=$1
21+
22+
local attempt
23+
24+
openstack volume create --size 2 $volume_name
25+
attempt=1
26+
while [[ $(openstack volume show $volume_name -f value -c status) != "available" ]]; do
27+
echo "Volume $volume_name not available yet"
28+
attempt=$((attempt+1))
29+
if [[ $attempt -eq 10 ]]; then
30+
echo "Volume $volume_name failed to become available"
31+
openstack volume show $volume_name
32+
return 1
33+
fi
34+
sleep 10
35+
done
36+
}
37+
38+
function attach_and_detach_a_volume {
39+
local volume_name=$1
40+
local instance_name=$2
41+
42+
local attempt
43+
44+
openstack server add volume $instance_name $volume_name --device /dev/vdb
45+
attempt=1
46+
while [[ $(openstack volume show $volume_name -f value -c status) != "in-use" ]]; do
47+
echo "Volume $volume_name not attached yet"
48+
attempt=$((attempt+1))
49+
if [[ $attempt -eq 10 ]]; then
50+
echo "Volume failed to attach"
51+
openstack volume show $volume_name
52+
return 1
53+
fi
54+
sleep 10
55+
done
56+
57+
openstack server remove volume $instance_name $volume_name
58+
attempt=1
59+
while [[ $(openstack volume show $volume_name -f value -c status) != "available" ]]; do
60+
echo "Volume $volume_name not detached yet"
61+
attempt=$((attempt+1))
62+
if [[ $attempt -eq 10 ]]; then
63+
echo "Volume failed to detach"
64+
openstack volume show $volume_name
65+
return 1
66+
fi
67+
sleep 10
68+
done
69+
}
70+
71+
function delete_a_volume {
72+
local volume_name=$1
73+
74+
local attempt
75+
local result
76+
77+
openstack volume delete $volume_name
78+
79+
attempt=1
80+
# NOTE(yoctozepto): This is executed outside of the `while` clause
81+
# *on purpose*. You see, bash is evil (TM) and will silence any error
82+
# happening in any "condition" clause (such as `if` or `while`) even with
83+
# `errexit` being set.
84+
result=$(openstack volume list --name $volume_name -f value -c ID)
85+
while [[ -n "$result" ]]; do
86+
echo "Volume $volume_name not deleted yet"
87+
attempt=$((attempt+1))
88+
if [[ $attempt -eq 10 ]]; then
89+
echo "Volume failed to delete"
90+
openstack volume show $volume_name
91+
return 1
92+
fi
93+
sleep 10
94+
result=$(openstack volume list --name $volume_name -f value -c ID)
95+
done
96+
}
97+
1998
function test_instance_boot {
2099
echo "TESTING: Server creation"
21100
openstack server create --wait --image cirros --flavor m1.tiny --key-name mykey --network demo-net kolla_boot_test
@@ -30,44 +109,28 @@ function test_instance_boot {
30109

31110
if [[ $SCENARIO == "ceph-ansible" ]] || [[ $SCENARIO == "zun" ]]; then
32111
echo "TESTING: Cinder volume attachment"
33-
openstack volume create --size 2 test_volume
34-
attempt=1
35-
while [[ $(openstack volume show test_volume -f value -c status) != "available" ]]; do
36-
echo "Volume not available yet"
37-
attempt=$((attempt+1))
38-
if [[ $attempt -eq 10 ]]; then
39-
echo "Volume failed to become available"
40-
openstack volume show test_volume
41-
return 1
42-
fi
43-
sleep 10
44-
done
45-
openstack server add volume kolla_boot_test test_volume --device /dev/vdb
46-
attempt=1
47-
while [[ $(openstack volume show test_volume -f value -c status) != "in-use" ]]; do
48-
echo "Volume not attached yet"
49-
attempt=$((attempt+1))
50-
if [[ $attempt -eq 10 ]]; then
51-
echo "Volume failed to attach"
52-
openstack volume show test_volume
53-
return 1
54-
fi
55-
sleep 10
56-
done
57-
openstack server remove volume kolla_boot_test test_volume
58-
attempt=1
59-
while [[ $(openstack volume show test_volume -f value -c status) != "available" ]]; do
60-
echo "Volume not detached yet"
61-
attempt=$((attempt+1))
62-
if [[ $attempt -eq 10 ]]; then
63-
echo "Volume failed to detach"
64-
openstack volume show test_volume
65-
return 1
66-
fi
67-
sleep 10
68-
done
69-
openstack volume delete test_volume
112+
113+
create_a_volume test_volume
114+
openstack volume show test_volume
115+
attach_and_detach_a_volume test_volume kolla_boot_test
116+
delete_a_volume test_volume
117+
70118
echo "SUCCESS: Cinder volume attachment"
119+
120+
if [[ $HAS_UPGRADE == 'yes' ]]; then
121+
echo "TESTING: Cinder volume upgrade stability (PHASE: $PHASE)"
122+
123+
if [[ $PHASE == 'deploy' ]]; then
124+
create_a_volume durable_volume
125+
openstack volume show durable_volume
126+
elif [[ $PHASE == 'upgrade' ]]; then
127+
openstack volume show durable_volume
128+
attach_and_detach_a_volume durable_volume kolla_boot_test
129+
delete_a_volume durable_volume
130+
fi
131+
132+
echo "SUCCESS: Cinder volume upgrade stability (PHASE: $PHASE)"
133+
fi
71134
fi
72135

73136
echo "TESTING: Floating ip allocation"

0 commit comments

Comments
 (0)