From 8f726129b2c658f500c0b04174fe71d45ee7fd1b Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Mon, 24 Jun 2024 18:20:15 +0000 Subject: [PATCH] Add a new client method: "get_loaded_network_extensions" This method retrieves the extensions loaded by the Neutron API, instead of reading the configured extensions in the tempest configuration. This method can help during a extension implementation, as for example in "subnet-external-network". This extension cannot be declared yet in the neutron-tempest-plugin job definitions, because the extension has not been implemented in Neutron. However, when the Neutron patch is tested, the extension is missing in the configuration and the test cannot correctly modify the API calls. Related-Bug: #2051831 Change-Id: I3e6f570cd63e44df7ceb8f5013c2b4adebfe4286 --- neutron_tempest_plugin/api/base.py | 10 ++++++++++ neutron_tempest_plugin/api/test_subnets.py | 5 ++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/neutron_tempest_plugin/api/base.py b/neutron_tempest_plugin/api/base.py index 7af37119..99fa946a 100644 --- a/neutron_tempest_plugin/api/base.py +++ b/neutron_tempest_plugin/api/base.py @@ -1221,6 +1221,16 @@ class BaseNetworkTest(test.BaseTestCase): client = client or ndp_proxy.get('client') or cls.client client.delete_ndp_proxy(ndp_proxy['id']) + @classmethod + def get_loaded_network_extensions(cls): + """Return the network service loaded extensions + + :return: list of strings with the alias of the network service loaded + extensions. + """ + body = cls.client.list_extensions() + return [net_ext['alias'] for net_ext in body['extensions']] + class BaseAdminNetworkTest(BaseNetworkTest): diff --git a/neutron_tempest_plugin/api/test_subnets.py b/neutron_tempest_plugin/api/test_subnets.py index f7a38a47..23574eea 100644 --- a/neutron_tempest_plugin/api/test_subnets.py +++ b/neutron_tempest_plugin/api/test_subnets.py @@ -11,7 +11,6 @@ # under the License. import netaddr -from tempest.common import utils as tutils from tempest.lib import decorators from neutron_tempest_plugin.api import base @@ -25,8 +24,6 @@ class SubnetsSearchCriteriaTest(base.BaseSearchCriteriaTest): @classmethod def resource_setup(cls): - if tutils.is_extension_enabled('subnet-external-network', 'network'): - cls.list_kwargs['router:external'] = False super(SubnetsSearchCriteriaTest, cls).resource_setup() net = cls.create_network(network_name='subnet-search-test-net') for name in cls.resource_names: @@ -70,6 +67,8 @@ class SubnetsSearchCriteriaTest(base.BaseSearchCriteriaTest): @decorators.idempotent_id('c0f9280b-9d81-4728-a967-6be22659d4c8') def test_list_validation_filters(self): + if 'subnet-external-network' in self.get_loaded_network_extensions(): + self.list_kwargs['router:external'] = False self._test_list_validation_filters(self.list_kwargs) self._test_list_validation_filters({ 'unknown_filter': 'value'}, filter_is_valid=False)