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
This commit is contained in:
Vladimir Ushakov 2016-03-17 13:14:17 +03:00
parent 16b3b509da
commit d2f5497bc2

View File

@ -180,7 +180,13 @@ class TestNeutronFailoverBase(base_test_case.TestBasic):
router_id = os_conn.get_routers_ids()[0] router_id = os_conn.get_routers_ids()[0]
devops_node = self.get_node_with_dhcp(os_conn, net_id) devops_node = self.get_node_with_dhcp(os_conn, net_id)
_ip = self.fuel_web.get_nailgun_node_by_name(devops_node.name)['ip'] _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') instance_keypair = os_conn.create_key(key_name='instancekey')
# create instance for check neutron migration processes # 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 # Find node with hosting l3 agent for router
nodes_with_l3 = os_conn.get_l3_agent_hosts(router_id) 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 " err_msg = ("Node with l3 agent from router:{r_id} after reset "
"old node with l3 agent not found.") "old node with l3 agent not found.")
if not nodes_with_l3:
raise NotFound(err_msg.format(router_id)) raise NotFound(err_msg.format(router_id))
node_with_l3 = nodes_with_l3[0] node_with_l3 = nodes_with_l3[0]
new_devops = self.get_node_with_l3(node_with_l3) new_devops = self.get_node_with_l3(node_with_l3)