Fix unittests for port-security and security-groups

Both test classes were not testing the actual plugin due to wrong
inheritance hierarchy.

Change-Id: Idf8057f0e43fc7b10c4f50800f1477ed61ce01d2
This commit is contained in:
Roey Chen 2015-11-04 08:38:31 -08:00
parent 579958e2ba
commit fed74dfcb6
4 changed files with 12 additions and 16 deletions

View File

@ -395,6 +395,8 @@ class NsxV3Plugin(addr_pair_db.AllowedAddressPairsMixin,
created_net = super(NsxV3Plugin, self).create_network(context, created_net = super(NsxV3Plugin, self).create_network(context,
network) network)
if psec.PORTSECURITY not in net_data:
net_data[psec.PORTSECURITY] = True
self._process_network_port_security_create( self._process_network_port_security_create(
context, net_data, created_net) context, net_data, created_net)
self._process_l3_create(context, created_net, net_data) self._process_l3_create(context, created_net, net_data)

View File

@ -20,7 +20,7 @@ from vmware_nsx.common import sync
from vmware_nsx.tests import unit as vmware from vmware_nsx.tests import unit as vmware
from vmware_nsx.tests.unit.nsx_mh.apiclient import fake from vmware_nsx.tests.unit.nsx_mh.apiclient import fake
from vmware_nsx.tests.unit.nsx_v3 import test_constants as v3_constants from vmware_nsx.tests.unit.nsx_v3 import test_constants as v3_constants
from vmware_nsx.tests.unit.nsxlib.v3 import nsxlib_testcase from vmware_nsx.tests.unit.nsx_v3 import test_plugin as test_nsxv3
from vmware_nsx.tests.unit import test_utils from vmware_nsx.tests.unit import test_utils
@ -48,13 +48,7 @@ class TestPortSecurityNSXv2(PortSecurityTestCaseNSXv2, psec.TestPortSecurity):
pass pass
class PortSecurityTestCaseNSXv3(nsxlib_testcase.NsxClientTestCase, class TestPortSecurityNSXv3(psec.TestPortSecurity,
psec.PortSecurityDBTestCase): test_nsxv3.NsxV3PluginTestCaseMixin):
def setUp(self, *args, **kwargs): def setUp(self, plugin=v3_constants.PLUGIN_NAME):
super(PortSecurityTestCaseNSXv3, self).setUp( super(TestPortSecurityNSXv3, self).setUp(plugin=plugin)
plugin=v3_constants.PLUGIN_NAME)
class TestPortSecurityNSXv3(PortSecurityTestCaseNSXv3,
psec.TestPortSecurity):
pass

View File

@ -77,8 +77,8 @@ class NsxPluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
attrs.update(providernet_args) attrs.update(providernet_args)
for arg in (('admin_state_up', 'tenant_id', 'shared') + for arg in (('admin_state_up', 'tenant_id', 'shared') +
(arg_list or ())): (arg_list or ())):
# Arg must be present and not empty # Arg must be present
if arg in kwargs and kwargs[arg]: if arg in kwargs:
data['network'][arg] = kwargs[arg] data['network'][arg] = kwargs[arg]
network_req = self.new_create_request('networks', data, fmt) network_req = self.new_create_request('networks', data, fmt)
if (kwargs.get('set_context') and 'tenant_id' in kwargs): if (kwargs.get('set_context') and 'tenant_id' in kwargs):

View File

@ -97,8 +97,8 @@ class NsxV3PluginTestCaseMixin(test_plugin.NeutronDbPluginV2TestCase,
attrs.update(providernet_args) attrs.update(providernet_args)
for arg in (('admin_state_up', 'tenant_id', 'shared') + for arg in (('admin_state_up', 'tenant_id', 'shared') +
(arg_list or ())): (arg_list or ())):
# Arg must be present and not empty # Arg must be present
if arg in kwargs and kwargs[arg]: if arg in kwargs:
data['network'][arg] = kwargs[arg] data['network'][arg] = kwargs[arg]
network_req = self.new_create_request('networks', data, fmt) network_req = self.new_create_request('networks', data, fmt)
if (kwargs.get('set_context') and 'tenant_id' in kwargs): if (kwargs.get('set_context') and 'tenant_id' in kwargs):
@ -133,7 +133,7 @@ class TestPortsV2(test_plugin.TestPortsV2, NsxV3PluginTestCaseMixin):
data['port']['fixed_ips']) data['port']['fixed_ips'])
class TestSecurityGroups(ext_sg.TestSecurityGroups, NsxV3PluginTestCaseMixin): class TestSecurityGroups(NsxV3PluginTestCaseMixin, ext_sg.TestSecurityGroups):
pass pass