Make test_router_is_scheduled_on_l3_agents compatible with dvr routers

In case of dvr routers IP addresses should be checked in the
qrouter- and also in snat- namespace as external gateway is configured
in the snat namespace in that case.
This patch adds check for snat- namespace when router is distributed.

Change-Id: Ia45fbfafd4adcd8bafdba050b3e4bebca1a5c7ff
This commit is contained in:
Slawek Kaplonski 2021-08-25 16:03:33 +02:00 committed by Federico Ressi
parent 804eb47be4
commit 36c7cfd07c
1 changed files with 16 additions and 8 deletions

View File

@ -97,20 +97,28 @@ class RouterTest(testtools.TestCase):
self._check_routers_namespace_on_host(router_agent['host'])
def _check_routers_namespace_on_host(self, hostname, state="master"):
router_namespace = "qrouter-%s" % self.router['id']
agent_host = topology.get_openstack_node(hostname=hostname)
namespaces = ip.list_network_namespaces(
ssh_client=agent_host.ssh_client)
self.assertIn(router_namespace, namespaces)
namespace_ips = ip.list_ip_addresses(
scope='global', network_namespace=router_namespace,
ssh_client=agent_host.ssh_client)
namespace_ips = self._get_router_ips_from_namespaces(hostname)
missing_ips = set(self.router_ips) - set(namespace_ips)
if state == "master":
self.assertFalse(missing_ips)
else:
self.assertTrue(missing_ips)
def _get_router_ips_from_namespaces(self, hostname):
agent_host = topology.get_openstack_node(hostname=hostname)
router_namespaces = ["qrouter-%s" % self.router['id']]
if self.router.get('distributed'):
router_namespaces.append("snat-%s" % self.router['id'])
host_namespaces = ip.list_network_namespaces(
ssh_client=agent_host.ssh_client)
ips = []
for router_namespace in router_namespaces:
self.assertIn(router_namespace, host_namespaces)
ips += ip.list_ip_addresses(
scope='global', network_namespace=router_namespace,
ssh_client=agent_host.ssh_client)
return ips
@neutron.skip_if_missing_networking_extensions('l3-ha')
@neutron.skip_if_missing_networking_agents(binary='neutron-l3-agent',