Skip to content

Commit 3b87df0

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "[CI] Test instance health after upgrade" into stable/victoria
2 parents 05ab9ff + e33e75c commit 3b87df0

File tree

1 file changed

+85
-25
lines changed

1 file changed

+85
-25
lines changed

tests/test-core-openstack.sh

Lines changed: 85 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,69 @@ function delete_a_volume {
9595
done
9696
}
9797

98-
function test_instance_boot {
99-
echo "TESTING: Server creation"
100-
openstack server create --wait --image cirros --flavor m1.tiny --key-name mykey --network demo-net kolla_boot_test
101-
openstack --debug server list
98+
function create_instance {
99+
local name=$1
100+
openstack server create --wait --image cirros --flavor m1.tiny --key-name mykey --network demo-net ${name}
102101
# If the status is not ACTIVE, print info and exit 1
103-
if [[ $(openstack server show kolla_boot_test -f value -c status) != "ACTIVE" ]]; then
102+
if [[ $(openstack server show ${name} -f value -c status) != "ACTIVE" ]]; then
104103
echo "FAILED: Instance is not active"
105-
openstack --debug server show kolla_boot_test
104+
openstack --debug server show ${name}
106105
return 1
107106
fi
107+
}
108+
109+
function delete_instance {
110+
local name=$1
111+
openstack server delete --wait ${name}
112+
}
113+
114+
function create_fip {
115+
openstack floating ip create public1 -f value -c floating_ip_address
116+
}
117+
118+
function delete_fip {
119+
local fip_addr=$1
120+
openstack floating ip delete ${fip_addr}
121+
}
122+
123+
function attach_fip {
124+
local instance_name=$1
125+
local fip_addr=$2
126+
openstack server add floating ip ${instance_name} ${fip_addr}
127+
}
128+
129+
function detach_fip {
130+
local instance_name=$1
131+
local fip_addr=$2
132+
openstack server remove floating ip ${instance_name} ${fip_addr}
133+
}
134+
135+
function test_ssh {
136+
local instance_name=$1
137+
local fip_addr=$2
138+
local attempts
139+
attempts=12
140+
for i in $(seq 1 ${attempts}); do
141+
if ping -c1 -W1 ${fip_addr} && ssh -v -o BatchMode=yes -o StrictHostKeyChecking=no cirros@${fip_addr} hostname; then
142+
break
143+
elif [[ $i -eq ${attempts} ]]; then
144+
echo "Failed to access server via SSH after ${attempts} attempts"
145+
echo "Console log:"
146+
openstack console log show ${instance_name} || true
147+
openstack --debug server show ${instance_name}
148+
return 1
149+
else
150+
echo "Cannot access server - retrying"
151+
fi
152+
sleep 10
153+
done
154+
}
155+
156+
function test_instance_boot {
157+
local fip_addr
158+
159+
echo "TESTING: Server creation"
160+
create_instance kolla_boot_test
108161
echo "SUCCESS: Server creation"
109162

110163
if [[ $SCENARIO == "ceph-ansible" ]] || [[ $SCENARIO == "zun" ]]; then
@@ -134,35 +187,42 @@ function test_instance_boot {
134187
fi
135188

136189
echo "TESTING: Floating ip allocation"
137-
fip_addr=$(openstack floating ip create public1 -f value -c floating_ip_address)
138-
openstack server add floating ip kolla_boot_test ${fip_addr}
190+
fip_addr=$(create_fip)
191+
attach_fip kolla_boot_test ${fip_addr}
139192
echo "SUCCESS: Floating ip allocation"
140193

141194
echo "TESTING: PING&SSH to floating ip"
142-
attempts=12
143-
for i in $(seq 1 ${attempts}); do
144-
if ping -c1 -W1 ${fip_addr} && ssh -v -o BatchMode=yes -o StrictHostKeyChecking=no cirros@${fip_addr} hostname; then
145-
break
146-
elif [[ $i -eq ${attempts} ]]; then
147-
echo "Failed to access server via SSH after ${attempts} attempts"
148-
echo "Console log:"
149-
openstack console log show kolla_boot_test
150-
return 1
151-
else
152-
echo "Cannot access server - retrying"
153-
fi
154-
sleep 10
155-
done
195+
test_ssh kolla_boot_test ${fip_addr}
156196
echo "SUCCESS: PING&SSH to floating ip"
157197

158198
echo "TESTING: Floating ip deallocation"
159-
openstack server remove floating ip kolla_boot_test ${fip_addr}
160-
openstack floating ip delete ${fip_addr}
199+
detach_fip kolla_boot_test ${fip_addr}
200+
delete_fip ${fip_addr}
161201
echo "SUCCESS: Floating ip deallocation"
162202

163203
echo "TESTING: Server deletion"
164-
openstack server delete --wait kolla_boot_test
204+
delete_instance kolla_boot_test
165205
echo "SUCCESS: Server deletion"
206+
207+
if [[ $HAS_UPGRADE == 'yes' ]]; then
208+
echo "TESTING: Instance (Nova and Neutron) upgrade stability (PHASE: $PHASE)"
209+
210+
if [[ $PHASE == 'deploy' ]]; then
211+
create_instance kolla_upgrade_test
212+
fip_addr=$(create_fip)
213+
attach_fip kolla_upgrade_test ${fip_addr}
214+
test_ssh kolla_upgrade_test ${fip_addr} # tested to see if the instance has not just failed booting already
215+
echo ${fip_addr} > /tmp/kolla_ci_pre_upgrade_fip_addr
216+
elif [[ $PHASE == 'upgrade' ]]; then
217+
fip_addr=$(cat /tmp/kolla_ci_pre_upgrade_fip_addr)
218+
test_ssh kolla_upgrade_test ${fip_addr}
219+
detach_fip kolla_upgrade_test ${fip_addr}
220+
delete_fip ${fip_addr}
221+
delete_instance kolla_upgrade_test
222+
fi
223+
224+
echo "SUCCESS: Instance (Nova and Neutron) upgrade stability (PHASE: $PHASE)"
225+
fi
166226
}
167227

168228
function test_openstack_logged {

0 commit comments

Comments
 (0)