Improvments in Makefile and Amulets

This commit is contained in:
Bilal Baqar 2015-08-24 09:24:20 -07:00
parent d6be75bbae
commit 3f103442d3
8 changed files with 33 additions and 36 deletions

View File

@ -1,14 +1,18 @@
#!/usr/bin/make
PYTHON := /usr/bin/env python
lint:
@flake8 --exclude hooks/charmhelpers hooks
@flake8 --exclude hooks/charmhelpers unit_tests
virtualenv:
virtualenv .venv
.venv/bin/pip install flake8 nose coverage mock pyyaml netifaces \
netaddr jinja2
lint: virtualenv
.venv/bin/flake8 --exclude hooks/charmhelpers hooks unit_tests tests
@charm proof
unit_test:
unit_test: virtualenv
@echo Starting tests...
@$(PYTHON) /usr/bin/nosetests --nologcapture unit_tests
@.venv/bin/nosetests --nologcapture --with-coverage unit_tests
bin/charm_helpers_sync.py:
@mkdir -p bin

View File

@ -6,7 +6,7 @@ Once deployed the charm triggers the necessary services for a PLUMgrid Gateway a
# Usage
Step by step instructions on using the charm:
Instructions on using the charm:
juju deploy neutron-api
juju deploy neutron-api-plumgrid

View File

@ -1,6 +1,7 @@
# Copyright (c) 2015, PLUMgrid Inc, http://plumgrid.com
# This file contains the class that generates context for PLUMgrid template files.
# This file contains the class that generates context for
# PLUMgrid template files.
from charmhelpers.core.hookenv import (
relation_ids,
@ -52,7 +53,8 @@ class PGGwContext(context.NeutronContext):
def pg_ctxt(self):
'''
Generated Config for all PLUMgrid templates inside the templates folder.
Generated Config for all PLUMgrid templates inside the
templates folder.
'''
pg_ctxt = super(PGGwContext, self).pg_ctxt()
if not pg_ctxt:

View File

@ -100,7 +100,9 @@ def ensure_files():
'''
Ensures PLUMgrid specific files exist before templates are written.
'''
write_file(SUDOERS_CONF, "\nnova ALL=(root) NOPASSWD: /opt/pg/bin/ifc_ctl_pp *\n", owner='root', group='root', perms=0o644)
write_file(SUDOERS_CONF,
"\nnova ALL=(root) NOPASSWD: /opt/pg/bin/ifc_ctl_pp *\n",
owner='root', group='root', perms=0o644)
def restart_pg():
@ -133,7 +135,8 @@ def remove_iovisor():
'''
Removes iovisor kernel module.
'''
_exec_cmd(cmd=['rmmod', 'iovisor'], error_msg='Error Loading Iovisor Kernel Module')
_exec_cmd(cmd=['rmmod', 'iovisor'],
error_msg='Error Loading Iovisor Kernel Module')
def check_interface_type():

View File

@ -9,7 +9,7 @@ class TestDeployment(unittest.TestCase):
def setUpClass(cls):
cls.deployment = amulet.Deployment(series='trusty')
cls.deployment.load_bundle_file(
bundle_file='files/plumgrid-gateway.yaml',
bundle_file='tests/files/plumgrid-gateway.yaml',
deployment_name='test')
try:
cls.deployment.setup(timeout=2000)
@ -21,20 +21,6 @@ class TestDeployment(unittest.TestCase):
except:
raise
def test_plumgrid_gateway_external_interface(self):
pg_sentry = self.deployment.sentry['plumgrid-gateway/0']
pg_options = self.deployment.services['plumgrid-gateway']['options']
external_interface = pg_options['external-interface']
if not external_interface:
amulet.raise_status(
amulet.FAIL,
msg='plumgrid external-interface parameter was not found.')
output, code = pg_sentry.run("ethtool {}".format(external_interface))
if code != 0:
amulet.raise_status(
amulet.FAIL,
msg='external interface not found on the host')
def test_plumgrid_gateway_started(self):
pg_sentry = self.deployment.sentry['plumgrid-gateway/0']
agent_state = pg_sentry.info['agent-state']

View File

@ -34,13 +34,16 @@ class PGGwContextTest(CharmTestCase):
@patch.object(charmhelpers.contrib.openstack.context, 'config')
@patch.object(charmhelpers.contrib.openstack.context, 'unit_private_ip')
@patch.object(charmhelpers.contrib.openstack.context, 'unit_get')
@patch.object(charmhelpers.contrib.openstack.context, 'config_flags_parser')
@patch.object(charmhelpers.contrib.openstack.context,
'config_flags_parser')
@patch.object(context.PGGwContext, '_save_flag_file')
@patch.object(context, '_pg_dir_settings')
@patch.object(charmhelpers.contrib.openstack.context, 'neutron_plugin_attribute')
@patch.object(charmhelpers.contrib.openstack.context,
'neutron_plugin_attribute')
@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,
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):
if section == "driver":

View File

@ -39,8 +39,7 @@ class PGGwHooksTests(CharmTestCase):
def setUp(self):
super(PGGwHooksTests, self).setUp(hooks, TO_PATCH)
#self.config.side_effect = self.test_config.get
# self.config.side_effect = self.test_config.get
hooks.hooks._config_save = False
def _call_hook(self, hookname):

View File

@ -31,7 +31,7 @@ class TestPGGwUtils(CharmTestCase):
def setUp(self):
super(TestPGGwUtils, self).setUp(nutils, TO_PATCH)
#self.config.side_effect = self.test_config.get
# self.config.side_effect = self.test_config.get
def tearDown(self):
# Reset cached cache
@ -50,10 +50,10 @@ class TestPGGwUtils(CharmTestCase):
self.os_release.return_value = 'trusty'
templating.OSConfigRenderer.side_effect = _mock_OSConfigRenderer
_regconfs = nutils.register_configs()
confs = ['/var/lib/libvirt/filesystems/plumgrid-data/conf/pg/plumgrid.conf',
'/var/lib/libvirt/filesystems/plumgrid-data/conf/etc/hostname',
'/var/lib/libvirt/filesystems/plumgrid-data/conf/etc/hosts',
'/var/lib/libvirt/filesystems/plumgrid-data/conf/pg/ifcs.conf']
confs = [nutils.PG_CONF,
nutils.PG_HN_CONF,
nutils.PG_HS_CONF,
nutils.PG_IFCS_CONF]
self.assertItemsEqual(_regconfs.configs, confs)
def test_resource_map(self):