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
This commit is contained in:
Rodolfo Alonso Hernandez 2024-06-24 18:20:15 +00:00
parent 96747587f1
commit 8f726129b2
2 changed files with 12 additions and 3 deletions

View File

@ -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):

View File

@ -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)