Updated unit tests for HA

This commit is contained in:
Hassaan Pasha 2015-08-10 21:45:08 +05:00
parent 88abf130b7
commit 563d4263d7
5 changed files with 14 additions and 8 deletions

BIN
.coverage

Binary file not shown.

View File

@ -17,13 +17,14 @@ def _pg_dir_settings():
'''
Inspects relation with PLUMgrid director.
'''
director_ips=[]
director_ips = []
for rid in relation_ids('plumgrid'):
for unit in related_units(rid):
rdata = relation_get(rid=rid, unit=unit)
director_ips.append(str(rdata['private-address']))
return director_ips
class PGGwContext(context.NeutronContext):
@property
@ -63,10 +64,10 @@ class PGGwContext(context.NeutronContext):
single_ip = True
for ip in pg_dir_settings:
if single_ip:
pg_dir_ips=str(ip)
pg_dir_ips = str(ip)
single_ip = False
else:
pg_dir_ips= pg_dir_ips + ',' + str(ip)
pg_dir_ips = pg_dir_ips + ',' + str(ip)
pg_ctxt['local_ip'] = pg_dir_ips
unit_hostname = get_unit_hostname()
pg_ctxt['pg_hostname'] = unit_hostname

View File

@ -51,6 +51,7 @@ def install():
@hooks.hook('plumgrid-relation-joined')
@hooks.hook('plumgrid-relation-changed')
def plumgrid_joined():
'''
This hook is run when relation between plumgrid-gateway and

View File

@ -135,6 +135,7 @@ def remove_iovisor():
'''
_exec_cmd(cmd=['rmmod', 'iovisor'], error_msg='Error Loading Iovisor Kernel Module')
def check_interface_type():
'''
Checks the interface. Support added for AWS deployments. There are 2
@ -143,13 +144,14 @@ def check_interface_type():
log("Checking Interface Type")
default_interface = "juju-br0"
AWS_interface = "eth0"
shell_output = subprocess.check_output(['brctl','show','juju-br0'])
output = re.split(' |\n|\t',shell_output)
shell_output = subprocess.check_output(['brctl', 'show', 'juju-br0'])
output = re.split(' |\n|\t', shell_output)
if output[10] == '':
return AWS_interface
else:
return default_interface
def ensure_mtu():
'''
Ensures required MTU of the underlying networking of the node.

View File

@ -1,10 +1,10 @@
from test_utils import CharmTestCase
from mock import patch
import pg_gw_context as context
import pg_gw_utils as utils
import charmhelpers
TO_PATCH = [
#'_pg_dir_settings',
'config',
'get_unit_hostname',
]
@ -38,7 +38,8 @@ class PGGwContextTest(CharmTestCase):
@patch.object(context.PGGwContext, '_save_flag_file')
@patch.object(context, '_pg_dir_settings')
@patch.object(charmhelpers.contrib.openstack.context, 'neutron_plugin_attribute')
def test_neutroncc_context_api_rel(self, _npa, _pg_dir_settings, _save_flag_file,
@patch.object(utils, 'check_interface_type')
def test_neutroncc_context_api_rel(self, _int_type, _npa, _pg_dir_settings, _save_flag_file,
_config_flag, _unit_get, _unit_priv_ip, _config,
_is_clus, _https, _ens_pkgs):
def mock_npa(plugin, section, manager):
@ -63,12 +64,13 @@ class PGGwContextTest(CharmTestCase):
_is_clus.return_value = False
_config_flag.return_value = False
_pg_dir_settings.return_value = {'pg_dir_ip': '192.168.100.201'}
_int_type.return_value = 'juju-br0'
napi_ctxt = context.PGGwContext()
expect = {
'ext_interface': "eth1",
'config': 'neutron.randomconfig',
'core_plugin': 'neutron.randomdriver',
'local_ip': '192.168.100.201',
'local_ip': 'pg_dir_ip',
'network_manager': 'neutron',
'neutron_plugin': 'plumgrid',
'neutron_security_groups': None,