Skip to content

Commit 83a9db2

Browse files
Dean Troyerjharbott
authored andcommitted
Retry floating IP tests
test_server_attach_detach_floating_ip() has a test for server add/remove floating IP that seems to be racy, add a retry loop to let neutron and nova do their thing before calling it bad. Change-Id: I999a0d7dae1706d746053bafb7ab4e3b791d0042
1 parent 3493948 commit 83a9db2

1 file changed

Lines changed: 36 additions & 4 deletions

File tree

openstackclient/tests/functional/compute/v2/test_server.py

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# under the License.
1212

1313
import json
14+
import time
1415
import uuid
1516

1617
from tempest.lib import exceptions
@@ -255,10 +256,24 @@ def test_server_attach_detach_floating_ip(self):
255256
floating_ip
256257
)
257258
self.assertEqual("", raw_output)
258-
cmd_output = json.loads(self.openstack(
259-
'server show -f json ' +
260-
name
261-
))
259+
260+
# Loop a few times since this is timing-sensitive
261+
# Just hard-code it for now, since there is no pause and it is
262+
# racy we shouldn't have to wait too long, a minute seems reasonable
263+
wait_time = 0
264+
while wait_time < 60:
265+
cmd_output = json.loads(self.openstack(
266+
'server show -f json ' +
267+
name
268+
))
269+
if floating_ip not in cmd_output['addresses']:
270+
# Hang out for a bit and try again
271+
print('retrying floating IP check')
272+
wait_time += 10
273+
time.sleep(10)
274+
else:
275+
break
276+
262277
self.assertIn(
263278
floating_ip,
264279
cmd_output['addresses'],
@@ -272,6 +287,23 @@ def test_server_attach_detach_floating_ip(self):
272287
)
273288
self.assertEqual("", raw_output)
274289

290+
# Loop a few times since this is timing-sensitive
291+
# Just hard-code it for now, since there is no pause and it is
292+
# racy we shouldn't have to wait too long, a minute seems reasonable
293+
wait_time = 0
294+
while wait_time < 60:
295+
cmd_output = json.loads(self.openstack(
296+
'server show -f json ' +
297+
name
298+
))
299+
if floating_ip in cmd_output['addresses']:
300+
# Hang out for a bit and try again
301+
print('retrying floating IP check')
302+
wait_time += 10
303+
time.sleep(10)
304+
else:
305+
break
306+
275307
cmd_output = json.loads(self.openstack(
276308
'server show -f json ' +
277309
name

0 commit comments

Comments
 (0)