6
class AmuletDeployment(object):
9
This class provides generic Amulet deployment and test runner
13
def __init__(self, series=None):
14
"""Initialize the deployment environment."""
19
self.d = amulet.Deployment(series=self.series)
21
self.d = amulet.Deployment()
23
def _add_services(self, this_service, other_services):
26
Add services to the deployment where this_service is the local charm
27
that we're testing and other_services are the other services that
28
are being used in the local amulet tests.
30
if this_service['name'] != os.path.basename(os.getcwd()):
31
s = this_service['name']
32
msg = "The charm's root directory name needs to be {}".format(s)
33
amulet.raise_status(amulet.FAIL, msg=msg)
35
if 'units' not in this_service:
36
this_service['units'] = 1
38
self.d.add(this_service['name'], units=this_service['units'])
40
for svc in other_services:
42
branch_location = svc['location']
44
branch_location = 'cs:{}/{}'.format(self.series, svc['name']),
46
branch_location = None
48
if 'units' not in svc:
51
self.d.add(svc['name'], charm=branch_location, units=svc['units'])
53
def _add_relations(self, relations):
54
"""Add all of the relations for the services."""
55
for k, v in relations.iteritems():
58
def _configure_services(self, configs):
59
"""Configure all of the services."""
60
for service, config in configs.iteritems():
61
self.d.configure(service, config)
64
"""Deploy environment and wait for all hooks to finish executing."""
66
self.d.setup(timeout=900)
67
self.d.sentry.wait(timeout=900)
68
except amulet.helpers.TimeoutError:
69
amulet.raise_status(amulet.FAIL, msg="Deployment timed out")
74
"""Run all of the methods that are prefixed with 'test_'."""
75
for test in dir(self):
76
if test.startswith('test_'):