5
class AmuletDeployment(object):
6
"""This class provides generic Amulet deployment and test runner
9
def __init__(self, series):
10
"""Initialize the deployment environment."""
12
self.d = amulet.Deployment(series=self.series)
14
def _get_charm_name(self, service_name):
15
"""Gets the charm name from the service name. Unique service names can
16
be specified with a '-service#' suffix (e.g. mysql-service1)."""
17
if re.match(r"^.*-service\d{1,3}$", service_name):
18
charm_name = re.sub('\-service\d{1,3}$', '', service_name)
20
charm_name = service_name
23
def _add_services(self, this_service, other_services):
24
"""Add services to the deployment where this_service is the local charm
25
that we're focused on testing and other_services are the other
26
charms that come from the charm store."""
27
name, units = range(2)
29
charm_name = self._get_charm_name(this_service[name])
30
self.d.add(this_service[name],
31
units=this_service[units])
33
for svc in other_services:
34
charm_name = self._get_charm_name(svc[name])
36
charm='cs:{}/{}'.format(self.series, charm_name),
39
def _add_relations(self, relations):
40
"""Add all of the relations for the services."""
41
for k, v in relations.iteritems():
44
def _configure_services(self, configs):
45
"""Configure all of the services."""
46
for service, config in configs.iteritems():
47
self.d.configure(service, config)
50
"""Deploy environment and wait for all hooks to finish executing."""
54
except amulet.helpers.TimeoutError:
55
amulet.raise_status(amulet.FAIL, msg="Deployment timed out")
60
"""Run all of the methods that are prefixed with 'test_'."""
61
for test in dir(self):
62
if test.startswith('test_'):