From f52975b4ee938d9d8ff871cb95b41da1b71448c6 Mon Sep 17 00:00:00 2001 From: dkumbhar Date: Thu, 15 Oct 2020 07:31:25 +0000 Subject: [PATCH] fix in https://review.opendev.org/#/c/758223 Change-Id: Iea9d4611fa44617ffec379b914c56326481d451b --- .../lib/feature_manager.py | 34 +++++++++++-------- .../services/openstack_network_clients.py | 9 +++-- .../scenario/test_octavia_loadbalancers.py | 4 +-- .../tests/scenario/test_new_case_coverage.py | 9 +++-- 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/vmware_nsx_tempest_plugin/lib/feature_manager.py b/vmware_nsx_tempest_plugin/lib/feature_manager.py index 7399176..ba3c320 100644 --- a/vmware_nsx_tempest_plugin/lib/feature_manager.py +++ b/vmware_nsx_tempest_plugin/lib/feature_manager.py @@ -1605,9 +1605,10 @@ class FeatureManager(traffic_manager.IperfManager, admin_state_up=True)['loadbalancer'] lb_id = self.loadbalancer['id'] self.octavia_admin_client.wait_for_load_balancer_status(lb_id) - self.addCleanup(test_utils.call_and_ignore_notfound_exc, - self.octavia_admin_client. - delete_octavia_load_balancer, lb_id) + if clean_up is None: + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.octavia_admin_client. + delete_octavia_load_balancer, lb_id) if barbican: tls_id = barbican_container["container_ref"] else: @@ -1620,10 +1621,11 @@ class FeatureManager(traffic_manager.IperfManager, allowed_cidrs=allowed_cidrs, default_tls_container_ref=tls_id )['listener'] - self.addCleanup(test_utils.call_and_ignore_notfound_exc, - self.octavia_admin_listener_client. - delete_octavia_listener, - self.listener['id']) + if clean_up is None: + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.octavia_admin_listener_client. + delete_octavia_listener, + self.listener['id']) self.octavia_admin_client.wait_for_load_balancer_status(lb_id) if l7policy and action != 'REDIRECT_TO_POOL': l7p = self.octavia_admin_l7policies_client.\ @@ -1660,20 +1662,22 @@ class FeatureManager(traffic_manager.IperfManager, session_persistence=session_persistence) self.octavia_admin_client.wait_for_load_balancer_status(lb_id) pool_id = self.pool['pool']['id'] - self.addCleanup(test_utils.call_and_ignore_notfound_exc, - self.octavia_admin_pools_client. - delete_octavia_pool, - pool_id) + if clean_up is None: + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.octavia_admin_pools_client. + delete_octavia_pool, + pool_id) if hm_type: self.healthmonitor = self.octavia_hm_client.\ create_octavia_hm(pool_id=pool_id, type=hm_type, delay=delay, timeout=timeout, max_retries=max_retries, name=lb_name) self.octavia_admin_client.wait_for_load_balancer_status(lb_id) - self.addCleanup(test_utils.call_and_ignore_notfound_exc, - self.octavia_hm_client. - delete_octavia_hm, - self.healthmonitor['healthmonitor']['id']) + if clean_up is None: + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.octavia_hm_client. + delete_octavia_hm, + self.healthmonitor['healthmonitor']['id']) self.members = [] for server_name in self.topology_servers.keys(): if count < member_count: diff --git a/vmware_nsx_tempest_plugin/services/openstack_network_clients.py b/vmware_nsx_tempest_plugin/services/openstack_network_clients.py index 19063f7..b299023 100644 --- a/vmware_nsx_tempest_plugin/services/openstack_network_clients.py +++ b/vmware_nsx_tempest_plugin/services/openstack_network_clients.py @@ -656,10 +656,13 @@ class OctaviaLB_Client(base.BaseNetworkClient): uri = self.resource_object_path % load_balancer_id return self.show_resource(uri, **fields) - def delete_octavia_load_balancer(self, load_balancer_id, cascade=False): + def delete_octavia_load_balancer(self, load_balancer_id): uri = self.resource_object_path % load_balancer_id - if cascade: - uri = uri + '?cascade=True' + return self.delete_resource(uri) + + def delete_octavia_load_balancer_with_cascade(self, load_balancer_id): + uri = self.resource_object_path % load_balancer_id + uri = uri + '?cascade=True' return self.delete_resource(uri) def show_octavia_lb_status_tree(self, load_balancer_id, **fields): diff --git a/vmware_nsx_tempest_plugin/tests/nsxv/scenario/test_octavia_loadbalancers.py b/vmware_nsx_tempest_plugin/tests/nsxv/scenario/test_octavia_loadbalancers.py index a8355fd..605734f 100644 --- a/vmware_nsx_tempest_plugin/tests/nsxv/scenario/test_octavia_loadbalancers.py +++ b/vmware_nsx_tempest_plugin/tests/nsxv/scenario/test_octavia_loadbalancers.py @@ -836,8 +836,8 @@ class OctaviaRoundRobin(feature_manager.FeatureManager): timeout=10, max_retries=5, name=lb_name) self.octavia_admin_client.wait_for_load_balancer_status(lb_id) - self.octavia_admin_client.delete_octavia_load_balancer(lb_id, - cascade=True) + self.octavia_admin_client.\ + delete_octavia_load_balancer_with_cascade(lb_id) self.octavia_admin_client.\ wait_for_load_balancer_status(lb_id, is_delete_op=True) lbs = self.octavia_admin_client.\ diff --git a/vmware_nsx_tempest_plugin/tests/scenario/test_new_case_coverage.py b/vmware_nsx_tempest_plugin/tests/scenario/test_new_case_coverage.py index ea00d00..ab7b320 100644 --- a/vmware_nsx_tempest_plugin/tests/scenario/test_new_case_coverage.py +++ b/vmware_nsx_tempest_plugin/tests/scenario/test_new_case_coverage.py @@ -45,7 +45,6 @@ class TestNewCase(feature_manager.FeatureManager): super(TestNewCase, cls).setup_clients() cls.cmgr_adm = cls.get_client_manager('admin') cls.cmgr_alt = cls.get_client_manager('alt') - cls.cmgr_adm = cls.get_client_manager('admin') cls.routers_client = cls.cmgr_adm.routers_client cls.networks_client = cls.cmgr_adm.networks_client cls.subnets_client = cls.cmgr_adm.subnets_client @@ -279,7 +278,7 @@ class TestNewCase(feature_manager.FeatureManager): """ self.create_topo_single_network( "route-port", create_instance=False) - p_client = self.ports_client + p_client = self.cmgr_adm.ports_client port = self.get_router_port(p_client) kwargs = {'port_security_enabled': True} self.assertRaises(exceptions.BadRequest, @@ -433,7 +432,7 @@ class TestNewCase(feature_manager.FeatureManager): # Create single network attached to router topo self.create_topo_single_network( "admin_state", create_instance=False) - ports = self.ports_client.list_ports() + ports = self.cmgr_adm.ports_client.list_ports() for port in ports['ports']: if 'device_owner' in port: if port['device_owner'] == "network:dhcp": @@ -452,7 +451,7 @@ class TestNewCase(feature_manager.FeatureManager): topology_dict = self.create_topo_single_network( "dhcp_port", create_instance=False) network_state = topology_dict['network_state'] - ports = self.ports_client.list_ports() + ports = self.cmgr_adm.ports_client.list_ports() for port in ports['ports']: if 'device_owner' in port: if port['device_owner'] == "network:dhcp" \ @@ -598,7 +597,7 @@ class TestNewCase(feature_manager.FeatureManager): 1) fix_ip = [ {'subnet_id': subnet_state.get('id'), - 'ip_address': network_cidr[0] + '.2'}] + 'ip_address': network_cidr[0] + '.222'}] args = {'fixed_ips': fix_ip, 'network_id': network_state['id']} self.assertRaises(exceptions.BadRequest, self.cmgr_adm.ports_client.create_port,