Add decorator to skip test in case when DVR router is used

Some tests are valid only for centralized routers, so it
adds a new decorator method skip_if_router_distributed to skip
tests when router used in the NetworkStackFixture is DVR.

It uses the new decorator in below test case:
 tobiko/tests/faults/neutron/test_ovs.py::OpenvswitchTest::test_recreate_physical_bridge

Change-Id: I46128d5f76eef7428b765232c705b7b1a6b760d5
This commit is contained in:
Slawek Kaplonski 2021-08-26 15:56:38 +02:00 committed by Federico Ressi
parent 07d0d8a0eb
commit 2353dc2b01
2 changed files with 18 additions and 1 deletions

View File

@ -291,6 +291,21 @@ class NetworkStackFixture(heat.HeatStackFixture):
requirements['router'] += 1 requirements['router'] += 1
return requirements return requirements
def is_router_distributed(self) -> bool:
if self.has_gateway:
tobiko.setup_fixture(self)
return bool(self.gateway_details.get('distributed'))
else:
return False
@classmethod
def skip_if_router_is_distributed(cls, reason: str = None):
fixture = tobiko.get_fixture(cls)
if reason is None:
reason = "Distributed router is not supported"
return tobiko.skip_if(reason=reason,
predicate=fixture.is_router_distributed)
@neutron.skip_if_missing_networking_extensions('net-mtu-writable') @neutron.skip_if_missing_networking_extensions('net-mtu-writable')
class NetworkWithNetMtuWriteStackFixture(NetworkStackFixture): class NetworkWithNetMtuWriteStackFixture(NetworkStackFixture):

View File

@ -31,7 +31,8 @@ from tobiko.tripleo import undercloud
@neutron.skip_if_missing_networking_agents(neutron.L3_AGENT) @neutron.skip_if_missing_networking_agents(neutron.L3_AGENT)
class OpenvswitchTest(testtools.TestCase): class OpenvswitchTest(testtools.TestCase):
stack = tobiko.required_setup_fixture(stacks.CirrosServerStackFixture) stack: stacks.ServerStackFixture = tobiko.required_fixture(
stacks.CirrosServerStackFixture)
def setUp(self): def setUp(self):
super(OpenvswitchTest, self).setUp() super(OpenvswitchTest, self).setUp()
@ -72,6 +73,7 @@ class OpenvswitchTest(testtools.TestCase):
raise neutron.AgentNotFoundOnHost(agent_type="neutron-ovs-agent", raise neutron.AgentNotFoundOnHost(agent_type="neutron-ovs-agent",
host=hostname) host=hostname)
@stacks.NetworkStackFixture.skip_if_router_is_distributed()
@undercloud.skip_if_missing_undercloud @undercloud.skip_if_missing_undercloud
def test_recreate_physical_bridge(self): def test_recreate_physical_bridge(self):
# Check if vm is reachable before test # Check if vm is reachable before test