@@ -95,16 +95,69 @@ function delete_a_volume {
95
95
done
96
96
}
97
97
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}
102
101
# 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
104
103
echo " FAILED: Instance is not active"
105
- openstack --debug server show kolla_boot_test
104
+ openstack --debug server show ${name}
106
105
return 1
107
106
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
108
161
echo " SUCCESS: Server creation"
109
162
110
163
if [[ $SCENARIO == " ceph-ansible" ]] || [[ $SCENARIO == " zun" ]]; then
@@ -134,35 +187,42 @@ function test_instance_boot {
134
187
fi
135
188
136
189
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}
139
192
echo " SUCCESS: Floating ip allocation"
140
193
141
194
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}
156
196
echo " SUCCESS: PING&SSH to floating ip"
157
197
158
198
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}
161
201
echo " SUCCESS: Floating ip deallocation"
162
202
163
203
echo " TESTING: Server deletion"
164
- openstack server delete --wait kolla_boot_test
204
+ delete_instance kolla_boot_test
165
205
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
166
226
}
167
227
168
228
function test_openstack_logged {
0 commit comments