From f89426fc0864eab9c29be159c5580656f5d3108e Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Mon, 26 Aug 2024 17:30:12 +0200 Subject: [PATCH] Ensure that private networks are also accounted Right now there're 3 types of networks that are created in devstack: * private * public * shared This affects amount of resources that Vitrage is expecting to see during one of tests. In order to ensure that we're accounting for each type of networks that are present in deployment and that expected number of resources is evaluated properly, we add extra logic of fetching assumed networks and incrementing the counter. Change-Id: Ib30db71a97bd40c3a73082c348c9eaff3adc43db --- .../tests/api/resources/test_resources.py | 9 +++++++-- vitrage_tempest_plugin/tests/common/neutron_utils.py | 9 ++------- vitrage_tempest_plugin/tests/common/nova_utils.py | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/vitrage_tempest_plugin/tests/api/resources/test_resources.py b/vitrage_tempest_plugin/tests/api/resources/test_resources.py index 55625c9..635dc0d 100644 --- a/vitrage_tempest_plugin/tests/api/resources/test_resources.py +++ b/vitrage_tempest_plugin/tests/api/resources/test_resources.py @@ -76,8 +76,13 @@ class TestResource(BaseVitrageTempest): # TODO(e0ne): split this test to verify that only network, # instance and port are returned to non-admin user. resources = self.vitrage_client.resource.list(all_tenants=False) - has_shared_network = neutron_utils.get_shared_network() - num_resources = 7 if has_shared_network else 6 + has_shared_network = neutron_utils.get_neutron_network('shared') + has_private_network = neutron_utils.get_neutron_network('private') + num_resources = 6 + if has_shared_network: + num_resources += 1 + if has_private_network: + num_resources += 1 self.assertThat(resources, matchers.HasLength(num_resources)) @utils.tempest_logger diff --git a/vitrage_tempest_plugin/tests/common/neutron_utils.py b/vitrage_tempest_plugin/tests/common/neutron_utils.py index 6dc29d7..190acd3 100644 --- a/vitrage_tempest_plugin/tests/common/neutron_utils.py +++ b/vitrage_tempest_plugin/tests/common/neutron_utils.py @@ -15,11 +15,6 @@ from vitrage_tempest_plugin.tests.common import general_utils as g_utils from vitrage_tempest_plugin.tests.common.tempest_clients import TempestClients -def get_public_network(): +def get_neutron_network(name): nets = TempestClients.neutron().list_networks() - return g_utils.first_match(nets['networks'], name='public') - - -def get_shared_network(): - nets = TempestClients.neutron().list_networks() - return g_utils.first_match(nets['networks'], name='shared') + return g_utils.first_match(nets['networks'], name=name) diff --git a/vitrage_tempest_plugin/tests/common/nova_utils.py b/vitrage_tempest_plugin/tests/common/nova_utils.py index 1ec80ce..8a3a9fa 100644 --- a/vitrage_tempest_plugin/tests/common/nova_utils.py +++ b/vitrage_tempest_plugin/tests/common/nova_utils.py @@ -29,7 +29,7 @@ def create_instances(num_instances=1, set_public_network=True, name='vm'): flavor = get_first_flavor() image = glance_utils.get_first_image() if set_public_network: - public_net = neutron_utils.get_public_network() + public_net = neutron_utils.get_neutron_network('public') if public_net: nics = [{'net-id': public_net['id']}]