From 2353dc2b01f795051cf072de59cf36eb671d159c Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Thu, 26 Aug 2021 15:56:38 +0200 Subject: [PATCH] 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 --- tobiko/openstack/stacks/_neutron.py | 15 +++++++++++++++ tobiko/tests/faults/neutron/test_ovs.py | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tobiko/openstack/stacks/_neutron.py b/tobiko/openstack/stacks/_neutron.py index cb6e3c892..09ec9f31e 100644 --- a/tobiko/openstack/stacks/_neutron.py +++ b/tobiko/openstack/stacks/_neutron.py @@ -291,6 +291,21 @@ class NetworkStackFixture(heat.HeatStackFixture): requirements['router'] += 1 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') class NetworkWithNetMtuWriteStackFixture(NetworkStackFixture): diff --git a/tobiko/tests/faults/neutron/test_ovs.py b/tobiko/tests/faults/neutron/test_ovs.py index 4b25e7f19..1d1dc8ded 100644 --- a/tobiko/tests/faults/neutron/test_ovs.py +++ b/tobiko/tests/faults/neutron/test_ovs.py @@ -31,7 +31,8 @@ from tobiko.tripleo import undercloud @neutron.skip_if_missing_networking_agents(neutron.L3_AGENT) class OpenvswitchTest(testtools.TestCase): - stack = tobiko.required_setup_fixture(stacks.CirrosServerStackFixture) + stack: stacks.ServerStackFixture = tobiko.required_fixture( + stacks.CirrosServerStackFixture) def setUp(self): super(OpenvswitchTest, self).setUp() @@ -72,6 +73,7 @@ class OpenvswitchTest(testtools.TestCase): raise neutron.AgentNotFoundOnHost(agent_type="neutron-ovs-agent", host=hostname) + @stacks.NetworkStackFixture.skip_if_router_is_distributed() @undercloud.skip_if_missing_undercloud def test_recreate_physical_bridge(self): # Check if vm is reachable before test