Amulet test fixes:

* Makefile:
    - Run flake8 on tests dir
    - Only run precise-icehouse and trusty-icehouse tests by default
      and increase test timeout
    - Fix charm-helpers sync target
  * t/00-setup: Simplify dependencies install
  * t/README: Mention charm-tools dependency
  * t/basic_deployment.py:
    - Turn off debugging (OpenStackAmuletUtils(ERROR))
    - Specify unstable charm deployment
    - Use dicts in add_services
    - Rename restart test
    - Cleanup on restart test failure
    - Drop fake fail debug function
This commit is contained in:
Corey Bryant 2014-10-07 18:32:59 +00:00
parent a2ce89d407
commit 05d6b57348
4 changed files with 38 additions and 25 deletions

View File

@ -2,17 +2,19 @@
PYTHON := /usr/bin/env python
lint:
@flake8 --exclude hooks/charmhelpers hooks unit_tests
@flake8 --exclude hooks/charmhelpers hooks unit_tests tests
@charm proof
unit_test:
@echo Starting unit tests...
@$(PYTHON) /usr/bin/nosetests --nologcapture --with-coverage unit_tests
test:
@echo Starting amulet deployment tests...
#NOTE(beisner): can remove -v after bug 1320357 is fixed
# https://bugs.launchpad.net/amulet/+bug/1320357
@juju test -v -p AMULET_HTTP_PROXY
@juju test -v -p AMULET_HTTP_PROXY --timeout 900 \
00-setup 14-basic-precise-icehouse 15-basic-trusty-icehouse
bin/charm_helpers_sync.py:
@mkdir -p bin
@ -21,7 +23,7 @@ bin/charm_helpers_sync.py:
sync: bin/charm_helpers_sync.py
@$(PYTHON) bin/charm_helpers_sync.py -c charm-helpers-hooks.yaml
@charm-helper-sync -c charm-helpers-tests.yaml
@$(PYTHON) bin/charm_helpers_sync.py -c charm-helpers-tests.yaml
publish: lint unit_test
bzr push lp:charms/cinder

View File

@ -4,7 +4,7 @@ set -ex
sudo add-apt-repository --yes ppa:juju/stable
sudo apt-get update --yes
sudo apt-get install --yes python-amulet
sudo apt-get install --yes python-keystoneclient
sudo apt-get install --yes python-cinderclient
sudo apt-get install --yes python-glanceclient
sudo apt-get install --yes python-amulet \
python-keystoneclient \
python-cinderclient \
python-glanceclient

View File

@ -1,6 +1,12 @@
This directory provides Amulet tests that focus on verification of Cinder
deployments.
In order to run tests, you'll need charm-tools installed (in addition to
juju, of course):
sudo add-apt-repository ppa:juju/stable
sudo apt-get update
sudo apt-get install charm-tools
If you use a web proxy server to access the web, you'll need to set the
AMULET_HTTP_PROXY environment variable to the http URL of the proxy server.

View File

@ -17,7 +17,7 @@ from charmhelpers.contrib.openstack.amulet.utils import ( # noqa
)
# Use DEBUG to turn on debug logging
u = OpenStackAmuletUtils(DEBUG)
u = OpenStackAmuletUtils(ERROR)
class CinderBasicDeployment(OpenStackAmuletDeployment):
@ -29,9 +29,10 @@ class CinderBasicDeployment(OpenStackAmuletDeployment):
# NOTE(beisner): Features and tests vary across Openstack releases.
# https://wiki.openstack.org/wiki/CinderSupportMatrix
def __init__(self, series=None, openstack=None, source=None):
def __init__(self, series=None, openstack=None, source=None, stable=False):
'''Deploy the entire test environment.'''
super(CinderBasicDeployment, self).__init__(series, openstack, source)
super(CinderBasicDeployment, self).__init__(series, openstack, source,
stable)
self._add_services()
self._add_relations()
self._configure_services()
@ -39,12 +40,15 @@ class CinderBasicDeployment(OpenStackAmuletDeployment):
self._initialize_tests()
def _add_services(self):
'''Add the service that we're testing, including the number of units,
where this charm is local, and the other charms are from
the charm store.'''
this_service = ('cinder', 1)
other_services = [('mysql', 1), ('rabbitmq-server', 1),
('keystone', 1), ('glance', 1)]
"""Add services
Add the services that we're testing, where cinder is local,
and the rest of the service are from lp branches that are
compatible with the local charm (e.g. stable or next).
"""
this_service = {'name': 'cinder'}
other_services = [{'name': 'mysql'}, {'name': 'rabbitmq-server'},
{'name': 'keystone'}, {'name': 'glance'}]
super(CinderBasicDeployment, self)._add_services(this_service,
other_services)
@ -508,10 +512,13 @@ class CinderBasicDeployment(OpenStackAmuletDeployment):
amulet.raise_status(amulet.FAIL,
msg='glance endpoint: {}'.format(ret))
def test_cinder_restart_on_config_change(self):
'''Verify that cinder services are restarted when
the config is changed.'''
def test_z_cinder_restart_on_config_change(self):
'''Verify cinder services are restarted when the config is changed.
Note(coreycb): The method name with the _z_ is a little odd
but it forces the test to run last. It just makes things
easier because restarting services requires re-authorization.
'''
u.log.debug('making charm config change')
self.d.configure('cinder', {'verbose': 'True'})
self.d.configure('cinder', {'debug': 'True'})
@ -519,11 +526,15 @@ class CinderBasicDeployment(OpenStackAmuletDeployment):
if not self.service_restarted(self.cinder_sentry, 'cinder-api',
'/etc/cinder/cinder.conf',
sleep_time=30):
self.d.configure('cinder', {'verbose': 'False'})
self.d.configure('cinder', {'debug': 'False'})
msg = "cinder-api service didn't restart after config change"
amulet.raise_status(amulet.FAIL, msg=msg)
if not self.service_restarted(self.cinder_sentry, 'cinder-volume',
'/etc/cinder/cinder.conf', sleep_time=0):
self.d.configure('cinder', {'verbose': 'False'})
self.d.configure('cinder', {'debug': 'False'})
msg = "cinder-volume service didn't restart after conf change"
amulet.raise_status(amulet.FAIL, msg=msg)
@ -806,9 +817,3 @@ class CinderBasicDeployment(OpenStackAmuletDeployment):
ret = self.delete_all_objs(self.cinder.volumes, item_desc='volume')
if ret:
amulet.raise_status(amulet.FAIL, msg=ret)
def test_zzzz_fake_fail(self):
'''Force a fake fail to keep juju environment after a successful test run'''
# Useful in test writing, when used with: juju test --set-e
amulet.raise_status(amulet.FAIL, msg='using fake fail to keep juju environment')