summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-01-18 23:53:32 +0000
committerGerrit Code Review <review@openstack.org>2017-01-18 23:53:32 +0000
commit854e515ce63e572a778e45baf51acab088a8f4dc (patch)
treee444a1b011e32f549e3077dea9589958377d1181 /openstackclient
parenta61c7cbba97ddedb0ed3a0c8ab874f7d13f936f5 (diff)
parent4a8e7dbe6b19e589e277e13d565578d98161572f (diff)
downloadpython-openstackclient-854e515ce63e572a778e45baf51acab088a8f4dc.tar.gz
Merge "Fix functional test for creating subnet"
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/tests/functional/network/v2/test_floating_ip.py39
1 files changed, 26 insertions, 13 deletions
diff --git a/openstackclient/tests/functional/network/v2/test_floating_ip.py b/openstackclient/tests/functional/network/v2/test_floating_ip.py
index fa9607a0..8fbec3d5 100644
--- a/openstackclient/tests/functional/network/v2/test_floating_ip.py
+++ b/openstackclient/tests/functional/network/v2/test_floating_ip.py
@@ -31,25 +31,38 @@ class FloatingIpTests(base.TestCase):
cls.re_description = re.compile("description\s+\|\s+([^|]+?)\s+\|")
cls.re_network_id = re.compile("floating_network_id\s+\|\s+(\S+)")
- # Make a random subnet
- cls.subnet = ".".join(map(
- str,
- (random.randint(0, 223) for _ in range(3))
- )) + ".0/26"
-
# Create a network for the floating ip
raw_output = cls.openstack(
'network create --external ' + cls.NETWORK_NAME
)
cls.network_id = re.search(cls.re_id, raw_output).group(1)
- # Create a subnet for the network
- raw_output = cls.openstack(
- 'subnet create ' +
- '--network ' + cls.NETWORK_NAME + ' ' +
- '--subnet-range ' + cls.subnet + ' ' +
- cls.SUBNET_NAME
- )
+ # Try random subnet range for subnet creating
+ # Because we can not determine ahead of time what subnets are already
+ # in use, possibly by another test running in parallel, try 4 times
+ for i in range(4):
+ # Make a random subnet
+ cls.subnet = ".".join(map(
+ str,
+ (random.randint(0, 223) for _ in range(3))
+ )) + ".0/26"
+ try:
+ # Create a subnet for the network
+ raw_output = cls.openstack(
+ 'subnet create ' +
+ '--network ' + cls.NETWORK_NAME + ' ' +
+ '--subnet-range ' + cls.subnet + ' ' +
+ cls.SUBNET_NAME
+ )
+ except Exception:
+ if (i == 3):
+ # raise the exception at the last time
+ raise
+ pass
+ else:
+ # break and no longer retry if create sucessfully
+ break
+
cls.subnet_id = re.search(cls.re_id, raw_output).group(1)
@classmethod