Fix up lint and unit tests. Unit tests needed fixing as _ensure_bridge has been removed from the OVSPluginContext in favour of doing it explicitly in configure_ovs()
This commit is contained in:
parent
fe1406ebec
commit
83d814c810
@ -122,6 +122,7 @@ class DVRSharedSecretContext(OSContextGenerator):
|
||||
ctxt = {}
|
||||
return ctxt
|
||||
|
||||
|
||||
class APIIdentityServiceContext(context.IdentityServiceContext):
|
||||
|
||||
def __init__(self):
|
||||
@ -139,4 +140,3 @@ class APIIdentityServiceContext(context.IdentityServiceContext):
|
||||
if ctxt['region']:
|
||||
return ctxt
|
||||
return ctxt
|
||||
|
||||
|
@ -4,15 +4,11 @@ from test_utils import patch_open
|
||||
from mock import patch
|
||||
import neutron_ovs_context as context
|
||||
import charmhelpers
|
||||
|
||||
TO_PATCH = [
|
||||
'resolve_address',
|
||||
'config',
|
||||
'unit_get',
|
||||
'add_bridge',
|
||||
'add_bridge_port',
|
||||
'service_running',
|
||||
'service_start',
|
||||
'service_restart',
|
||||
'get_host_ip',
|
||||
]
|
||||
|
||||
@ -44,8 +40,10 @@ class OVSPluginContextTest(CharmTestCase):
|
||||
self.test_config.set('data-port', 'br-data:em1')
|
||||
config.side_effect = self.test_config.get
|
||||
mock_resolve_ports.side_effect = lambda ports: ports
|
||||
self.assertEquals(context.DataPortContext()(),
|
||||
{'br-data': 'em1'})
|
||||
self.assertEquals(
|
||||
charmhelpers.contrib.openstack.context.DataPortContext()(),
|
||||
{'br-data': 'em1'}
|
||||
)
|
||||
|
||||
@patch('charmhelpers.contrib.openstack.context.config')
|
||||
@patch('charmhelpers.contrib.openstack.context.get_nic_hwaddr')
|
||||
@ -62,8 +60,10 @@ class OVSPluginContextTest(CharmTestCase):
|
||||
config.side_effect = self.test_config.get
|
||||
list_nics.return_value = machine_machs.keys()
|
||||
get_nic_hwaddr.side_effect = lambda nic: machine_machs[nic]
|
||||
self.assertEquals(context.DataPortContext()(),
|
||||
{'br-d2': 'em1'})
|
||||
self.assertEquals(
|
||||
charmhelpers.contrib.openstack.context.DataPortContext()(),
|
||||
{'br-d2': 'em1'}
|
||||
)
|
||||
|
||||
@patch.object(charmhelpers.contrib.openstack.context, 'relation_get')
|
||||
@patch.object(charmhelpers.contrib.openstack.context, 'relation_ids')
|
||||
@ -101,7 +101,6 @@ class OVSPluginContextTest(CharmTestCase):
|
||||
}
|
||||
_rget.side_effect = lambda *args, **kwargs: rdata
|
||||
self.get_host_ip.return_value = '127.0.0.15'
|
||||
self.service_running.return_value = False
|
||||
napi_ctxt = context.OVSPluginContext()
|
||||
expect = {
|
||||
'neutron_alchemy_flags': {},
|
||||
@ -125,7 +124,6 @@ class OVSPluginContextTest(CharmTestCase):
|
||||
'vlan_ranges': 'physnet1:1000:2000',
|
||||
}
|
||||
self.assertEquals(expect, napi_ctxt())
|
||||
self.service_start.assertCalled()
|
||||
|
||||
@patch.object(charmhelpers.contrib.openstack.context, 'relation_get')
|
||||
@patch.object(charmhelpers.contrib.openstack.context, 'relation_ids')
|
||||
@ -168,7 +166,6 @@ class OVSPluginContextTest(CharmTestCase):
|
||||
}
|
||||
_rget.side_effect = lambda *args, **kwargs: rdata
|
||||
self.get_host_ip.return_value = '127.0.0.15'
|
||||
self.service_running.return_value = False
|
||||
napi_ctxt = context.OVSPluginContext()
|
||||
expect = {
|
||||
'distributed_routing': False,
|
||||
@ -192,7 +189,6 @@ class OVSPluginContextTest(CharmTestCase):
|
||||
'vlan_ranges': 'physnet1:1000:2000',
|
||||
}
|
||||
self.assertEquals(expect, napi_ctxt())
|
||||
self.service_start.assertCalled()
|
||||
|
||||
|
||||
class L3AgentContextTest(CharmTestCase):
|
||||
@ -272,7 +268,6 @@ class DVRSharedSecretContext(CharmTestCase):
|
||||
_NeutronAPIContext):
|
||||
_NeutronAPIContext.side_effect = fake_context({'enable_dvr': True})
|
||||
_shared_secret.return_value = 'secret_thing'
|
||||
#_use_dvr.return_value = True
|
||||
self.resolve_address.return_value = '10.0.0.10'
|
||||
self.assertEquals(context.DVRSharedSecretContext()(),
|
||||
{'shared_secret': 'secret_thing',
|
||||
|
@ -22,8 +22,8 @@ TO_PATCH = [
|
||||
'os_release',
|
||||
'neutron_plugin_attribute',
|
||||
'full_restart',
|
||||
'service_running',
|
||||
'service_restart',
|
||||
'service_running',
|
||||
'ExternalPortContext',
|
||||
]
|
||||
|
||||
@ -111,7 +111,7 @@ class TestNeutronOVSUtils(CharmTestCase):
|
||||
_use_dvr.return_value = True
|
||||
_map = nutils.resource_map()
|
||||
svcs = ['neutron-plugin-openvswitch-agent', 'neutron-metadata-agent',
|
||||
'neutron-vpn-agent']
|
||||
'neutron-l3-agent']
|
||||
confs = [nutils.NEUTRON_CONF]
|
||||
[self.assertIn(q_conf, _map.keys()) for q_conf in confs]
|
||||
self.assertEqual(_map[nutils.NEUTRON_CONF]['services'], svcs)
|
||||
@ -187,7 +187,7 @@ class TestNeutronOVSUtils(CharmTestCase):
|
||||
@patch.object(nutils, 'use_dvr')
|
||||
@patch('charmhelpers.contrib.openstack.context.config')
|
||||
def test_configure_ovs_ovs_ext_port(self, mock_config, _use_dvr):
|
||||
_use_dvr.return_value = False
|
||||
_use_dvr.return_value = True
|
||||
mock_config.side_effect = self.test_config.get
|
||||
self.config.side_effect = self.test_config.get
|
||||
self.test_config.set('ext-port', 'eth0')
|
||||
|
Loading…
x
Reference in New Issue
Block a user