From d2f5497bc2c129704b9fc39a60025a8df0192d24 Mon Sep 17 00:00:00 2001 From: Vladimir Ushakov Date: Thu, 17 Mar 2016 13:14:17 +0300 Subject: [PATCH] Handling of 'list index out of range' in neutron_l3_migration test. nodes_with_l3 = os_conn.get_l3_agent_hosts(router_id)[0] could cause a 'list index out of range' exception if l3 agent hosting router with id was not found. Change-Id: Ic5df53191fbf57114f0c65fdf307a3e41a1db0a1 Closes-Bug: #1551696 --- .../tests/tests_strength/test_neutron_base.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fuelweb_test/tests/tests_strength/test_neutron_base.py b/fuelweb_test/tests/tests_strength/test_neutron_base.py index 016446c32..300bab716 100644 --- a/fuelweb_test/tests/tests_strength/test_neutron_base.py +++ b/fuelweb_test/tests/tests_strength/test_neutron_base.py @@ -180,7 +180,13 @@ class TestNeutronFailoverBase(base_test_case.TestBasic): router_id = os_conn.get_routers_ids()[0] devops_node = self.get_node_with_dhcp(os_conn, net_id) _ip = self.fuel_web.get_nailgun_node_by_name(devops_node.name)['ip'] - node_with_l3 = os_conn.get_l3_agent_hosts(router_id)[0] + nodes_with_l3 = os_conn.get_l3_agent_hosts(router_id) + if not nodes_with_l3: + err_msg = ("Node with l3 agent from router:{r_id} after reset " + "old node with l3 agent not found.") + raise NotFound(err_msg.format(router_id)) + node_with_l3 = nodes_with_l3[0] + instance_keypair = os_conn.create_key(key_name='instancekey') # create instance for check neutron migration processes @@ -288,9 +294,9 @@ class TestNeutronFailoverBase(base_test_case.TestBasic): # Find node with hosting l3 agent for router nodes_with_l3 = os_conn.get_l3_agent_hosts(router_id) - err_msg = ("Node with l3 agent from router:{r_id} after reset " - "old node with l3 agent not found.") if not nodes_with_l3: + err_msg = ("Node with l3 agent from router:{r_id} after reset " + "old node with l3 agent not found.") raise NotFound(err_msg.format(router_id)) node_with_l3 = nodes_with_l3[0] new_devops = self.get_node_with_l3(node_with_l3)