3
Charms have the capability to declare that they support more than
4
one series. Previously a separate copy of the charm was required for
5
each series. An important constraint here is that for a given charm,
6
all of the listed series must be for the same distro/OS; it is not
7
allowed to offer a single charm for Ubuntu and CentOS for example.
8
Supported series are added to charm metadata as follows:
11
summary: "Great software"
18
The default series is the first in the list:
22
should deploy a mycharm service running on trusty.
24
A different, non-default series may be specified:
26
juju deploy mycharm --series precise
28
It is possible to force the charm to deploy using an unsupported series
29
(so long as the underlying OS is compatible):
31
juju deploy mycharm --series xenial --force
34
from __future__ import print_function
37
from collections import namedtuple
43
from deploy_stack import BootstrapManager
44
from jujucharm import (
49
add_basic_testing_arguments,
54
from assess_heterogeneous_control import check_series
59
log = logging.getLogger("assess_multi_series_charms")
62
Test = namedtuple("Test", ["series", "service", "force", "success", "machine",
66
def assess_multi_series_charms(client):
67
"""Assess multi series charms.
69
:param client: Juju client.
70
:type client: jujupy.EnvJujuClient
74
Test(series="precise", service='test0', force=False, success=False,
75
machine=None, juju1x_supported=False),
76
Test(series=None, service='test1', force=False, success=True,
77
machine='0', juju1x_supported=True),
78
Test(series="trusty", service='test2', force=False, success=True,
79
machine='1', juju1x_supported=True),
80
Test(series="xenial", service='test3', force=False, success=True,
81
machine='2', juju1x_supported=False),
82
Test(series="precise", service='test4', force=True, success=True,
83
machine='3', juju1x_supported=False),
85
with temp_dir() as repository:
87
charm = Charm(charm_name, 'Test charm', series=['trusty', 'xenial'])
88
charm_dir = charm.to_repo_dir(repository)
89
charm_path = local_charm_path(
90
charm=charm_name, juju_ver=client.version, series='trusty',
91
repository=os.path.dirname(charm_dir))
93
if client.is_juju1x() and not test.juju1x_supported:
96
"Assessing multi series charms: test: {} charm_dir:{}".format(
98
assert_deploy(client, test, charm_path, repository=repository)
100
check_series(client, machine=test.machine, series=test.series)
103
def assert_deploy(client, test, charm_path, repository=None):
104
"""Deploy a charm and assert a success or fail.
106
:param client: Juju client
107
:type client: jujupy.EnvJujuClient
108
:param test: Deploy test data.
112
:param repository: Direcotry path to the repository
113
:type repository: str
117
client.deploy(charm=charm_path, series=test.series,
118
service=test.service, force=test.force,
119
repository=repository)
120
client.wait_for_started()
123
client.deploy(charm=charm_path, series=test.series,
124
service=test.service, force=test.force,
125
repository=repository)
126
except subprocess.CalledProcessError:
128
raise JujuAssertionError('Assert deploy failed for {}'.format(test))
131
def parse_args(argv):
132
"""Parse all arguments."""
133
parser = argparse.ArgumentParser(
134
description="Test multi series charm feature")
135
add_basic_testing_arguments(parser)
136
return parser.parse_args(argv)
140
args = parse_args(argv)
141
configure_logging(args.verbose)
142
bs_manager = BootstrapManager.from_args(args)
143
with bs_manager.booted_context(args.upload_tools):
144
assess_multi_series_charms(bs_manager.client)
148
if __name__ == '__main__':