From a48f364cff1e64e7c24f8a99c6315bd2a144b00d Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Wed, 29 Nov 2017 12:59:54 +0200 Subject: [PATCH] NSX|V3: upgrade NSX version in the unit tests to 2.2 Upgrading the NSX-V3 unittests to use the highest nsx version currently available (2.2) Using NSX version 2.1 or higher in the unittests initializes the LB driver, so we will disable the load balancer driver callbacks since it shouldn't be called on non-lbaas tests. Change-Id: Ib450a683fde68fd13ee1a291d496d0d73c9fd671 --- vmware_nsx/tests/unit/nsx_v3/test_dhcp_metadata.py | 3 +++ vmware_nsx/tests/unit/nsx_v3/test_plugin.py | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/vmware_nsx/tests/unit/nsx_v3/test_dhcp_metadata.py b/vmware_nsx/tests/unit/nsx_v3/test_dhcp_metadata.py index d4e2edf103..d3e5a27e19 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_dhcp_metadata.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_dhcp_metadata.py @@ -288,12 +288,15 @@ class NsxNativeDhcpTestCase(test_plugin.NsxV3PluginTestCaseMixin): def test_dhcp_service_with_create_dhcp_subnet_in_vlan_network(self): # Test if a DHCP-enabled subnet cannot be created in a vlan network. + # on nsx version that does not support it povidernet_args = {pnet.NETWORK_TYPE: 'vlan', pnet.PHYSICAL_NETWORK: 'tzuuid', pnet.SEGMENTATION_ID: 100} with mock.patch( 'vmware_nsxlib.v3.core_resources.NsxLibTransportZone.' 'get_transport_type', return_value='VLAN'),\ + mock.patch.object(self.plugin.nsxlib, 'feature_supported', + return_value=False),\ self.network(providernet_args=povidernet_args, arg_list=(pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK, diff --git a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py index d8427176b8..e82be3c9cc 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py @@ -160,7 +160,7 @@ def _mock_nsx_backend_calls(): mock.patch( "vmware_nsxlib.v3.NsxLib.get_version", - return_value='1.1.0').start() + return_value='2.2.0').start() mock.patch( "vmware_nsxlib.v3.load_balancer.Service.get_router_lb_service", @@ -994,6 +994,11 @@ class L3NatTest(test_l3_plugin.L3BaseForIntTests, NsxV3PluginTestCaseMixin, 'is_nsx_version_2_0_0', new=lambda v: True) mock_nsx_version.start() + # Make sure the LB callback is not called on router deletion + self.lb_mock = mock.patch( + "vmware_nsx.services.lbaas.nsx_v3.lb_driver_v2." + "EdgeLoadbalancerDriverV2._check_lb_service_on_router") + self.lb_mock.start() super(L3NatTest, self).setUp( plugin=plugin, ext_mgr=ext_mgr, service_plugins=service_plugins) @@ -1079,6 +1084,7 @@ class TestL3NatTestCase(L3NatTest, self.skipTest('not supported') def test_router_delete_with_lb_service(self): + self.lb_mock.stop() # Create the LB object - here the delete callback is registered lb_driver = lb_driver_v2.EdgeLoadbalancerDriverV2() with self.router() as router: @@ -1090,6 +1096,7 @@ class TestL3NatTestCase(L3NatTest, router['router']['id']) # Unregister callback lb_driver._unsubscribe_router_delete_callback() + self.lb_mock.start() def test_multiple_subnets_on_different_routers(self): with self.network() as network: