diff --git a/vmware_nsx_tempest_plugin/tests/api/test_qos.py b/vmware_nsx_tempest_plugin/tests/api/test_qos.py index ecce0ee..9e832f4 100644 --- a/vmware_nsx_tempest_plugin/tests/api/test_qos.py +++ b/vmware_nsx_tempest_plugin/tests/api/test_qos.py @@ -69,6 +69,7 @@ class BaseQosTest(base.BaseAdminNetworkTest): body = client_mgr.ports_client.create_port( network_id=network['id'], **kwargs) port = body.get('port', body) + cls.ports = [] cls.ports.append(port) return port @@ -424,15 +425,11 @@ class QosPolicyTest(BaseQosTest): network = self.create_shared_network('test network') self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.delete_network, network['id']) - port = self.create_port(network, qos_policy_id=policy['id'], - client_mgr=self.primary_mgr) - self.addCleanup(test_utils.call_and_ignore_notfound_exc, - self.delete_port, port['id']) - retrieved_port = self.show_port(port['id'], - client_mgr=self.primary_mgr) - # check if port is not attached to the policy - self.assertIsNone(retrieved_port['qos_policy_id'], - 'Error:Port is attached to qos policy') + self.assertRaises( + exceptions.NotFound, + self.create_port, + network, + qos_policy_id=policy['id'], client_mgr=self.primary_mgr) @decorators.attr(type='nsxv3') @decorators.idempotent_id('f8163237-fba9-4db5-9526-bad6d2343c76') diff --git a/vmware_nsx_tempest_plugin/tests/nsxv/api/lbaas/base.py b/vmware_nsx_tempest_plugin/tests/nsxv/api/lbaas/base.py index 6b23040..0b7a639 100644 --- a/vmware_nsx_tempest_plugin/tests/nsxv/api/lbaas/base.py +++ b/vmware_nsx_tempest_plugin/tests/nsxv/api/lbaas/base.py @@ -86,6 +86,7 @@ class BaseTestCase(base.BaseNetworkTest): cls.subnet = cls.create_subnet(cls.network) cls.tenant_id = cls.subnet.get('tenant_id') cls.subnet_id = cls.subnet.get('id') + cls.ports = [] # NSX-v: load-balancer's subnet need to attach to exclusive-router if CONF.network.backend == "nsxv3": router_cfg = dict( diff --git a/vmware_nsx_tempest_plugin/tests/nsxv3/api/test_nsx_floating_ip.py b/vmware_nsx_tempest_plugin/tests/nsxv3/api/test_nsx_floating_ip.py index 3fb9d2e..7d51d12 100644 --- a/vmware_nsx_tempest_plugin/tests/nsxv3/api/test_nsx_floating_ip.py +++ b/vmware_nsx_tempest_plugin/tests/nsxv3/api/test_nsx_floating_ip.py @@ -50,8 +50,9 @@ class NSXv3FloatingIPTest(base.BaseNetworkTest): cls.router = cls.create_router(data_utils.rand_name('router-'), external_network_id=cls.ext_net_id) cls.create_router_interface(cls.router['id'], cls.subnet['id']) + cls.ports = [] for i in range(2): - cls.create_port(cls.network) + cls.ports.append(cls.create_port(cls.network)) cls.nsx = nsxv3_client.NSXV3Client(CONF.nsxv3.nsx_manager, CONF.nsxv3.nsx_user, CONF.nsxv3.nsx_password) diff --git a/vmware_nsx_tempest_plugin/tests/nsxv3/scenario/test_mdproxy.py b/vmware_nsx_tempest_plugin/tests/nsxv3/scenario/test_mdproxy.py index 2abdaea..636a5d8 100644 --- a/vmware_nsx_tempest_plugin/tests/nsxv3/scenario/test_mdproxy.py +++ b/vmware_nsx_tempest_plugin/tests/nsxv3/scenario/test_mdproxy.py @@ -27,6 +27,7 @@ LOG = logging.getLogger(__name__) class TestMDProxy(feature_manager.FeatureManager): + """Test MDProxy. Adding test cases to test MDProxy in different scenarios such as @@ -100,48 +101,54 @@ class TestMDProxy(feature_manager.FeatureManager): md_counter = 0 logical_ports = self.nsx.get_os_logical_ports() for port_index in range(len(logical_ports)): - if logical_ports[port_index]["attachment"][ - "attachment_type"] == "METADATA_PROXY": - if logical_ports[port_index]["tags"][0]["tag"] == network_id: - msg = "MDproxy logical port does not have proper tenant " \ - "id!!!" + if "attachment" in logical_ports[port_index]: + if logical_ports[port_index]["attachment"][ + "attachment_type"] == "METADATA_PROXY": + if logical_ports[port_index][ + "tags"][0]["tag"] == network_id: + msg = "MDproxy logical port does not "\ + "have proper tenant "\ + "id!!!" + self.assertEqual( + tenant_id, logical_ports[port_index]["tags"][1][ + "tag"], msg) + md_counter += 1 + msg1 = "Admin state of MDProxy logical port is DOWN!!!" + msg2 = "LS name does not start with mdproxy!!!" + msg3 = "MDproxy logical port does not have any auto tag!!!" + msg4 = "MDproxy logical port does not have scope tag as " \ + "os-neutron-net-id!!!" + msg5 = "MDproxy logical port does not have scope tag as " \ + "os-project-id!!!" + msg6 = "MDproxy logical port does not have scope tag as " \ + "os-project-name!!!" + msg7 = "MDproxy logical port does not have scope tag as " \ + "os-api-version!!!" self.assertEqual( - tenant_id, logical_ports[port_index]["tags"][1][ - "tag"], msg) - md_counter += 1 - msg1 = "Admin state of MDProxy logical port is DOWN!!!" - msg2 = "LS name does not start with mdproxy!!!" - msg3 = "MDproxy logical port does not have any auto tag!!!" - msg4 = "MDproxy logical port does not have scope tag as " \ - "os-neutron-net-id!!!" - msg5 = "MDproxy logical port does not have scope tag as " \ - "os-project-id!!!" - msg6 = "MDproxy logical port does not have scope tag as " \ - "os-project-name!!!" - msg7 = "MDproxy logical port does not have scope tag as " \ - "os-api-version!!!" - self.assertEqual( - "UP", logical_ports[port_index]["admin_state"], msg1) - self.assertIn("mdproxy-", - logical_ports[port_index]["display_name"], msg2) - self.assertNotEqual(0, len(logical_ports[port_index]["tags"]), - msg3) - self.assertEqual( - "os-neutron-net-id", - logical_ports[port_index]["tags"][0]["scope"], - msg4) - self.assertEqual( - "os-project-id", - logical_ports[port_index]["tags"][1]["scope"], - msg5) - self.assertEqual( - "os-project-name", - logical_ports[port_index]["tags"][2]["scope"], - msg6) - self.assertEqual( - "os-api-version", - logical_ports[port_index]["tags"][3]["scope"], - msg7) + "UP", logical_ports[port_index]["admin_state"], msg1) + self.assertIn("mdproxy-", + logical_ports[port_index]["display_name"], + msg2) + self.assertNotEqual( + 0, + len(logical_ports[port_index]["tags"]), + msg3) + self.assertEqual( + "os-neutron-net-id", + logical_ports[port_index]["tags"][0]["scope"], + msg4) + self.assertEqual( + "os-project-id", + logical_ports[port_index]["tags"][1]["scope"], + msg5) + self.assertEqual( + "os-project-name", + logical_ports[port_index]["tags"][2]["scope"], + msg6) + self.assertEqual( + "os-api-version", + logical_ports[port_index]["tags"][3]["scope"], + msg7) self.assertNotEqual(0, md_counter, "No logical port found for MD " "proxy!!!") diff --git a/vmware_nsx_tempest_plugin/tests/nsxv3/scenario/test_nsx_port_security.py b/vmware_nsx_tempest_plugin/tests/nsxv3/scenario/test_nsx_port_security.py index 54c2992..0aa958b 100644 --- a/vmware_nsx_tempest_plugin/tests/nsxv3/scenario/test_nsx_port_security.py +++ b/vmware_nsx_tempest_plugin/tests/nsxv3/scenario/test_nsx_port_security.py @@ -123,12 +123,14 @@ class TestNSXv3PortSecurityScenario(manager.NetworkScenarioTest): def get_port_id(self, network_id, subnet_id, instance): _, instance_addr = instance["addresses"].items()[0] instance_fixed_ip = instance_addr[0]["addr"] + port_id = None for port in self._list_ports(): - port_fixed_ip = port["fixed_ips"][0]["ip_address"] - if port["network_id"] == network_id and port["fixed_ips"][0][ + if "fixed_ips" in port: + port_fixed_ip = port["fixed_ips"][0]["ip_address"] + if port["network_id"] == network_id and port["fixed_ips"][0][ "subnet_id"] == subnet_id and instance["id"] == port[ - "device_id"] and port_fixed_ip == instance_fixed_ip: - port_id = port["id"] + "device_id"] and port_fixed_ip == instance_fixed_ip: + port_id = port["id"] self.assertIsNotNone(port_id, "Failed to find Instance's port id!!!") return port_id diff --git a/vmware_nsx_tempest_plugin/tests/nsxv3/scenario/test_provider_security_group.py b/vmware_nsx_tempest_plugin/tests/nsxv3/scenario/test_provider_security_group.py index dbc43e0..f77ca31 100644 --- a/vmware_nsx_tempest_plugin/tests/nsxv3/scenario/test_provider_security_group.py +++ b/vmware_nsx_tempest_plugin/tests/nsxv3/scenario/test_provider_security_group.py @@ -134,12 +134,14 @@ class TestProviderSecurityGroup(manager.NetworkScenarioTest): def get_port_id(self, network_id, subnet_id, instance): _, instance_addr = instance["addresses"].items()[0] instance_fixed_ip = instance_addr[0]["addr"] + port_id = None for port in self._list_ports(): - port_fixed_ip = port["fixed_ips"][0]["ip_address"] - if port["network_id"] == network_id and port["fixed_ips"][0][ + if "fixed_ips" in port: + port_fixed_ip = port["fixed_ips"][0]["ip_address"] + if port["network_id"] == network_id and port["fixed_ips"][0][ "subnet_id"] == subnet_id and instance["id"] == port[ - "device_id"] and port_fixed_ip == instance_fixed_ip: - port_id = port["id"] + "device_id"] and port_fixed_ip == instance_fixed_ip: + port_id = port["id"] self.assertIsNotNone(port_id, "Failed to find Instance's port id!!!") return port_id