From: Paul Michali Date: Tue, 29 Jul 2014 19:18:34 +0000 (-0400) Subject: VPNaaS: Enable UT cases with newer oslo.messaging X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=799b895ee1c5c9b3244b8f90ddfa0750c696bae4;p=openstack-build%2Fneutron-build.git VPNaaS: Enable UT cases with newer oslo.messaging 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 --- diff --git a/neutron/tests/unit/services/vpn/service_drivers/test_cisco_ipsec.py b/neutron/tests/unit/services/vpn/service_drivers/test_cisco_ipsec.py index 36259b380..9414dc91c 100644 --- a/neutron/tests/unit/services/vpn/service_drivers/test_cisco_ipsec.py +++ b/neutron/tests/unit/services/vpn/service_drivers/test_cisco_ipsec.py @@ -13,12 +13,13 @@ # 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): diff --git a/neutron/tests/unit/services/vpn/service_drivers/test_ipsec.py b/neutron/tests/unit/services/vpn/service_drivers/test_ipsec.py index e288748ff..b2aab3a6b 100644 --- a/neutron/tests/unit/services/vpn/service_drivers/test_ipsec.py +++ b/neutron/tests/unit/services/vpn/service_drivers/test_ipsec.py @@ -14,17 +14,16 @@ # 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):