Browse Source

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
tags/2014.2.b3
Paul Michali Henry Gessau 5 years ago
parent
commit
799b895ee1
2 changed files with 43 additions and 39 deletions
  1. +21
    -17
      neutron/tests/unit/services/vpn/service_drivers/test_cisco_ipsec.py
  2. +22
    -22
      neutron/tests/unit/services/vpn/service_drivers/test_ipsec.py

+ 21
- 17
neutron/tests/unit/services/vpn/service_drivers/test_cisco_ipsec.py View File

@@ -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):


+ 22
- 22
neutron/tests/unit/services/vpn/service_drivers/test_ipsec.py View File

@@ -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):


Loading…
Cancel
Save