From 925188d2d5c6e10cc3bb5cd7bcc0f2f3e677df1e Mon Sep 17 00:00:00 2001 From: Martin Kopec Date: Tue, 7 May 2019 13:26:34 +0000 Subject: [PATCH] Make test_hotplug_nic test first check the IP The test doesn't take into account that the interface can already be associated with the IP address, configured by NetworkManager. Therefore the review adds a check if the IP is already set. Change-Id: I4eede97c041b44d9a7bb754e5ccc1ebb194a2e4b --- tempest/scenario/test_network_basic_ops.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py index 7992585ad3..f46c7e8c20 100644 --- a/tempest/scenario/test_network_basic_ops.py +++ b/tempest/scenario/test_network_basic_ops.py @@ -292,11 +292,14 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest): % CONF.network.build_timeout) _, new_nic = self.diff_list[0] - ssh_client.exec_command("sudo ip addr add %s/%s dev %s" % ( - new_port['fixed_ips'][0]['ip_address'], - CONF.network.project_network_mask_bits, - new_nic)) - ssh_client.exec_command("sudo ip link set %s up" % new_nic) + ip_output = ssh_client.exec_command('ip a') + ip_address = new_port['fixed_ips'][0]['ip_address'] + ip_mask = CONF.network.project_network_mask_bits + # check if the address is not already in use, if not, set it + if ' ' + ip_address + '/' + str(ip_mask) not in ip_output: + ssh_client.exec_command("sudo ip addr add %s/%s dev %s" % ( + ip_address, ip_mask, new_nic)) + ssh_client.exec_command("sudo ip link set %s up" % new_nic) def _get_server_nics(self, ssh_client): reg = re.compile(r'(?P\d+): (?P\w+)[@]?.*:')