]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
VPNaaS: Enable UT cases with newer oslo.messaging
authorPaul Michali <pcm@cisco.com>
Tue, 29 Jul 2014 19:18:34 +0000 (15:18 -0400)
committerHenry Gessau <gessau@cisco.com>
Fri, 22 Aug 2014 03:13:03 +0000 (23:13 -0400)
Now that 1.4.0.0a3 of oslo.messaging has been added to Neutron
requirements, the unit test cases in VPNaaS code can be
uncommented and included in the tests. These tests ensure that
the correct validator is called, when validation is performed.
This adds similar tests to the reference and Cisco VPNaaS
implementation.

Change-Id: I62e3f8f3ec5fcceccd13891b1aa142869e1d88a1
Closes-Bug: 1349829

neutron/tests/unit/services/vpn/service_drivers/test_cisco_ipsec.py
neutron/tests/unit/services/vpn/service_drivers/test_ipsec.py

index 36259b380334435b81316d362b91141dc5e0a8c0..9414dc91c4e0dd723b7a7e0fa92e657b94b6a049 100644 (file)
 #    under the License.
 
 import mock
-from oslo.config import cfg
+from oslo.config import cfg
 
 from neutron import context as n_ctx
+from neutron.db import servicetype_db as st_db
 from neutron.openstack.common import uuidutils
 from neutron.plugins.common import constants
-from neutron.services.vpn import plugin as vpn_plugin
+from neutron.services.vpn import plugin as vpn_plugin
 from neutron.services.vpn.service_drivers import cisco_csr_db as csr_db
 from neutron.services.vpn.service_drivers import cisco_ipsec as ipsec_driver
 from neutron.services.vpn.service_drivers import cisco_validator as validator
@@ -53,21 +54,24 @@ CISCO_IPSEC_SERVICE_DRIVER = ('neutron.services.vpn.service_drivers.'
                               'cisco_ipsec.CiscoCsrIPsecVPNDriver')
 
 
-# class TestCiscoValidatorSelection(base.BaseTestCase):
-#
-#     def setUp(self):
-#         super(TestCiscoValidatorSelection, self).setUp()
-#         vpnaas_provider = (constants.VPN + ':vpnaas:' +
-#                            CISCO_IPSEC_SERVICE_DRIVER + ':default')
-#         cfg.CONF.set_override('service_provider',
-#                               [vpnaas_provider],
-#                               'service_providers')
-#         mock.patch('neutron.common.rpc.create_connection').start()
-#         self.vpn_plugin = vpn_plugin.VPNDriverPlugin()
-#
-#     def test_reference_driver_used(self):
-#         self.assertIsInstance(self.vpn_plugin._get_validator(),
-#                               validator.CiscoCsrVpnValidator)
+class TestCiscoValidatorSelection(base.BaseTestCase):
+
+    def setUp(self):
+        super(TestCiscoValidatorSelection, self).setUp()
+        vpnaas_provider = (constants.VPN + ':vpnaas:' +
+                           CISCO_IPSEC_SERVICE_DRIVER + ':default')
+        cfg.CONF.set_override('service_provider',
+                              [vpnaas_provider],
+                              'service_providers')
+        stm = st_db.ServiceTypeManager()
+        mock.patch('neutron.db.servicetype_db.ServiceTypeManager.get_instance',
+                   return_value=stm).start()
+        mock.patch('neutron.common.rpc.create_connection').start()
+        self.vpn_plugin = vpn_plugin.VPNDriverPlugin()
+
+    def test_reference_driver_used(self):
+        self.assertIsInstance(self.vpn_plugin._get_validator(),
+                              validator.CiscoCsrVpnValidator)
 
 
 class TestCiscoIPsecDriverValidation(base.BaseTestCase):
index e288748ffb95a096c8c929bbc06f491a38f6f3f4..b2aab3a6b15a4ce11b9032f49a4321852f75bd15 100644 (file)
 #    under the License.
 
 import mock
-# TODO(pcm): Uncomment once oslo.messaging 1.4.0.0a2 or newer is available
-# from oslo.config import cfg
+from oslo.config import cfg
 
 from neutron import context as n_ctx
 from neutron.db import l3_db
+from neutron.db import servicetype_db as st_db
 from neutron.db.vpn import vpn_validator
 from neutron.extensions import vpnaas
 from neutron.openstack.common import uuidutils
 from neutron.plugins.common import constants
-# TODO(pcm): Uncomment once oslo.messaging 1.4.0.0a2 or newer is available
-# from neutron.services.vpn import plugin as vpn_plugin
+from neutron.services.vpn import plugin as vpn_plugin
 from neutron.services.vpn.service_drivers import ipsec as ipsec_driver
 from neutron.tests import base
 
@@ -47,24 +46,25 @@ IPV6 = 6
 IPSEC_SERVICE_DRIVER = ('neutron.services.vpn.service_drivers.'
                         'ipsec.IPsecVPNDriver')
 
-# TODO(pcm): Uncomment, once oslo.messaging package 1.4.0.0a2 or
-# newer is released and available for Neutron.
-#
-# class TestValidatorSelection(base.BaseTestCase):
-#
-#     def setUp(self):
-#         super(TestValidatorSelection, self).setUp()
-#         vpnaas_provider = (constants.VPN + ':vpnaas:' +
-#                            IPSEC_SERVICE_DRIVER + ':default')
-#         cfg.CONF.set_override('service_provider',
-#                               [vpnaas_provider],
-#                               'service_providers')
-#         mock.patch('neutron.common.rpc.create_connection').start()
-#         self.vpn_plugin = vpn_plugin.VPNDriverPlugin()
-#
-#     def test_reference_driver_used(self):
-#         self.assertIsInstance(self.vpn_plugin._get_validator(),
-#                               vpn_validator.VpnReferenceValidator)
+
+class TestValidatorSelection(base.BaseTestCase):
+
+    def setUp(self):
+        super(TestValidatorSelection, self).setUp()
+        vpnaas_provider = (constants.VPN + ':vpnaas:' +
+                           IPSEC_SERVICE_DRIVER + ':default')
+        cfg.CONF.set_override('service_provider',
+                              [vpnaas_provider],
+                              'service_providers')
+        mock.patch('neutron.common.rpc.create_connection').start()
+        stm = st_db.ServiceTypeManager()
+        mock.patch('neutron.db.servicetype_db.ServiceTypeManager.get_instance',
+                   return_value=stm).start()
+        self.vpn_plugin = vpn_plugin.VPNDriverPlugin()
+
+    def test_reference_driver_used(self):
+        self.assertIsInstance(self.vpn_plugin._get_validator(),
+                              vpn_validator.VpnReferenceValidator)
 
 
 class TestIPsecDriverValidation(base.BaseTestCase):