From 102514d125badb820901aecb41d99a509ee0afd9 Mon Sep 17 00:00:00 2001 From: Andrey Pavlov Date: Sat, 26 Nov 2016 15:48:29 +0300 Subject: [PATCH] fix tests for network_interface sometimes test tried to assign current address again and failed. Change-Id: I86498821cf89692c325dd17f4df96f8a08d1575f --- api/test_network_interfaces.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/api/test_network_interfaces.py b/api/test_network_interfaces.py index 56f4999..75bcdcf 100644 --- a/api/test_network_interfaces.py +++ b/api/test_network_interfaces.py @@ -236,7 +236,19 @@ class NetworkInterfaceTest(base.EC2TestCase): self.client.delete_network_interface, NetworkInterfaceId=ni_id) self.get_network_interface_waiter().wait_available(ni_id) - addresses = ['10.7.0.10', '10.7.0.11'] + ni = self.client.describe_network_interfaces( + NetworkInterfaceIds=[ni_id])['NetworkInterfaces'] + ni_addr = ni[0]['PrivateIpAddresses'][0]['PrivateIpAddress'] + + # add two more addresses to interface. + # check that they does not equal to current. + addresses = [] + for i in range(10, 13): + addr = '10.7.0.%d' % i + if addr != ni_addr: + addresses.append(addr) + if len(addresses) >= 2: + break data = self.client.assign_private_ip_addresses( NetworkInterfaceId=ni_id, PrivateIpAddresses=addresses)