summaryrefslogtreecommitdiff
path: root/openstackclient/tests/functional
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2018-06-28 13:35:38 -0500
committerJens Harbott <j.harbott@x-ion.de>2018-07-06 10:24:16 +0000
commit83a9db280d2c9dd749c65ff635c430348bd356c0 (patch)
tree54045d6b2fcca29fe0227faa875b51355473e776 /openstackclient/tests/functional
parent3493948d13aadd1a329b37eb8fafb731b1f5c6a7 (diff)
downloadpython-openstackclient-83a9db280d2c9dd749c65ff635c430348bd356c0.tar.gz
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
Diffstat (limited to 'openstackclient/tests/functional')
-rw-r--r--openstackclient/tests/functional/compute/v2/test_server.py40
1 files changed, 36 insertions, 4 deletions
diff --git a/openstackclient/tests/functional/compute/v2/test_server.py b/openstackclient/tests/functional/compute/v2/test_server.py
index 0b29fe5f..bba16f62 100644
--- a/openstackclient/tests/functional/compute/v2/test_server.py
+++ b/openstackclient/tests/functional/compute/v2/test_server.py
@@ -11,6 +11,7 @@
# under the License.
import json
+import time
import uuid
from tempest.lib import exceptions
@@ -255,10 +256,24 @@ class ServerTests(common.ComputeTestCase):
floating_ip
)
self.assertEqual("", raw_output)
- cmd_output = json.loads(self.openstack(
- 'server show -f json ' +
- name
- ))
+
+ # Loop a few times since this is timing-sensitive
+ # Just hard-code it for now, since there is no pause and it is
+ # racy we shouldn't have to wait too long, a minute seems reasonable
+ wait_time = 0
+ while wait_time < 60:
+ cmd_output = json.loads(self.openstack(
+ 'server show -f json ' +
+ name
+ ))
+ if floating_ip not in cmd_output['addresses']:
+ # Hang out for a bit and try again
+ print('retrying floating IP check')
+ wait_time += 10
+ time.sleep(10)
+ else:
+ break
+
self.assertIn(
floating_ip,
cmd_output['addresses'],
@@ -272,6 +287,23 @@ class ServerTests(common.ComputeTestCase):
)
self.assertEqual("", raw_output)
+ # Loop a few times since this is timing-sensitive
+ # Just hard-code it for now, since there is no pause and it is
+ # racy we shouldn't have to wait too long, a minute seems reasonable
+ wait_time = 0
+ while wait_time < 60:
+ cmd_output = json.loads(self.openstack(
+ 'server show -f json ' +
+ name
+ ))
+ if floating_ip in cmd_output['addresses']:
+ # Hang out for a bit and try again
+ print('retrying floating IP check')
+ wait_time += 10
+ time.sleep(10)
+ else:
+ break
+
cmd_output = json.loads(self.openstack(
'server show -f json ' +
name