Merge ~barryprice/charm-canonical-livepatch/+git/canonical-livepatch-charm:multiseries-testing into ~livepatch-charmers/charm-canonical-livepatch:master

Proposed by Barry Price
Status: Work in progress
Proposed branch: ~barryprice/charm-canonical-livepatch/+git/canonical-livepatch-charm:multiseries-testing
Merge into: ~livepatch-charmers/charm-canonical-livepatch:master
Diff against target: 139 lines (+26/-21)
1 file modified
tests/multiseries (+26/-21)
Reviewer Review Type Date Requested Status
Livepatch charm developers Pending
Review via email: mp+358136@code.launchpad.net

Commit message

First attempt at multi-series testing

To post a comment you must log in.

Unmerged commits

45c714c... by Barry Price

First attempt at multi-series testing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/tests/99-autogen b/tests/multiseries
index d7bed72..41d46a1 100755
--- a/tests/99-autogen
+++ b/tests/multiseries
@@ -7,38 +7,41 @@ from yaml import safe_load
77
88
9class TestDeployment(unittest.TestCase):9class TestDeployment(unittest.TestCase):
10
11 series = 'bionic' # latest LTS
12
10 @classmethod13 @classmethod
11 def setUpClass(cls):14 def setUpClass(cls):
12 cls.deployment = amulet.Deployment(series='bionic')15 cls.deployment = amulet.Deployment(series=series)
1316
14 # deploy mongodb as our parent17 # deploy mongodb as our parent
15 cls.deployment.add('mongodb')18 cls.deployment.add('mongodb-{}'.format(series), 'mongodb')
1619
17 # deploy our own charm20 # deploy our own charm
18 cls.deployment.add('canonical-livepatch')21 cls.deployment.add('livepatch-{}'.format(series), 'canonical-livepatch')
1922
20 # and deploy the nrpe subordinate to test nagios checks23 # and deploy the nrpe subordinate to test nagios checks
21 cls.deployment.add('nrpe')24 cls.deployment.add('nrpe-{}'.format(series), 'nrpe')
2225
23 # set nrpe to export its definitions26 # set nrpe to export its definitions
24 cls.deployment.configure('nrpe', {27 cls.deployment.configure('nrpe-{}'.format(series), {
25 'export_nagios_definitions': True,28 'export_nagios_definitions': True,
26 })29 })
2730
28 # relate subordinates to parent charm31 # relate subordinates to parent charm
29 cls.deployment.relate(32 cls.deployment.relate(
30 'mongodb:juju-info',33 'mongodb-{}:juju-info'.format(series),
31 'canonical-livepatch:juju-info'34 'livepatch-{}:juju-info'.format(series)
32 )35 )
33 cls.deployment.relate(36 cls.deployment.relate(
34 'mongodb:nrpe-external-master',37 'mongodb-{}:nrpe-external-master'.format(series),
35 'nrpe:nrpe-external-master'38 'nrpe-{}:nrpe-external-master'.format(series)
36 )39 )
3740
38 # relate livepatch to nrpe for its own nagios checks41 # relate livepatch to nrpe for its own nagios checks
39 cls.deployment.relate(42 cls.deployment.relate(
40 'canonical-livepatch:nrpe-external-master',43 'livepatch-{}:nrpe-external-master'.format(series),
41 'nrpe:nrpe-external-master'44 'nrpe-{}:nrpe-external-master'.format(series)
42 )45 )
4346
44 try:47 try:
@@ -51,7 +54,7 @@ class TestDeployment(unittest.TestCase):
51 )54 )
5255
53 def test_install(self):56 def test_install(self):
54 livepatch = self.deployment.sentry['canonical-livepatch'][0]57 livepatch = self.deployment.sentry['livepatch-{}'.format(series)][0]
5558
56 # verify the snap was installed59 # verify the snap was installed
57 output, exit_code = livepatch.run(60 output, exit_code = livepatch.run(
@@ -60,14 +63,14 @@ class TestDeployment(unittest.TestCase):
60 self.assertEqual(exit_code, 0)63 self.assertEqual(exit_code, 0)
6164
62 def test_status(self):65 def test_status(self):
63 livepatch = self.deployment.sentry['canonical-livepatch'][0]66 livepatch = self.deployment.sentry['livepatch-{}'.format(series)][0]
6467
65 # run a status check - we expect this to return 1 due to no access key68 # run a status check - we expect this to return 1 due to no access key
66 output, exit_code = livepatch.run('sudo canonical-livepatch status')69 output, exit_code = livepatch.run('sudo canonical-livepatch status')
67 self.assertEqual(exit_code, 1)70 self.assertEqual(exit_code, 1)
6871
69 def test_nagios_init(self):72 def test_nagios_init(self):
70 livepatch = self.deployment.sentry['canonical-livepatch'][0]73 livepatch = self.deployment.sentry['livepatch-{}'.format(series)][0]
7174
72 # check for nagios bits75 # check for nagios bits
73 for path in [76 for path in [
@@ -79,12 +82,12 @@ class TestDeployment(unittest.TestCase):
79 self.assertEqual(exit_code, 0)82 self.assertEqual(exit_code, 0)
8083
81 def test_nagios_context_change(self):84 def test_nagios_context_change(self):
82 livepatch = self.deployment.sentry['canonical-livepatch'][0]85 livepatch = self.deployment.sentry['livepatch-{}'.format(series)][0]
8386
84 test_context_name = 'amulet1'87 test_context_name = 'amulet1'
8588
86 # set context name89 # set context name
87 self.deployment.configure('canonical-livepatch', {90 self.deployment.configure('livepatch-{}'.format(series), {
88 'nagios_context': test_context_name,91 'nagios_context': test_context_name,
89 })92 })
9093
@@ -99,7 +102,7 @@ class TestDeployment(unittest.TestCase):
99 self.assertEqual(exit_code, 0)102 self.assertEqual(exit_code, 0)
100103
101 def test_channel_change(self):104 def test_channel_change(self):
102 livepatch = self.deployment.sentry['canonical-livepatch'][0]105 livepatch = self.deployment.sentry['livepatch-{}'.format(series)][0]
103106
104 # verify the current channel107 # verify the current channel
105 output, exit_code = livepatch.run('snap info canonical-livepatch')108 output, exit_code = livepatch.run('snap info canonical-livepatch')
@@ -111,7 +114,7 @@ class TestDeployment(unittest.TestCase):
111 self.assertEqual(channel, 'stable')114 self.assertEqual(channel, 'stable')
112115
113 # change channel to 'beta'116 # change channel to 'beta'
114 self.deployment.configure('canonical-livepatch', {117 self.deployment.configure('livepatch-{}'.format(series), {
115 'snap_channel': 'beta',118 'snap_channel': 'beta',
116 })119 })
117120
@@ -128,12 +131,12 @@ class TestDeployment(unittest.TestCase):
128 self.assertEqual(channel, 'beta')131 self.assertEqual(channel, 'beta')
129132
130 def test_nagios_servicegroup_change(self):133 def test_nagios_servicegroup_change(self):
131 livepatch = self.deployment.sentry['canonical-livepatch'][0]134 livepatch = self.deployment.sentry['livepatch-{}'.format(series)][0]
132135
133 test_servicegroup_name = 'amulet2'136 test_servicegroup_name = 'amulet2'
134137
135 # set servicegroup name138 # set servicegroup name
136 self.deployment.configure('canonical-livepatch', {139 self.deployment.configure('livepatch-{}'.format(series), {
137 'nagios_servicegroups': test_servicegroup_name,140 'nagios_servicegroups': test_servicegroup_name,
138 })141 })
139142
@@ -150,4 +153,6 @@ class TestDeployment(unittest.TestCase):
150153
151154
152if __name__ == '__main__':155if __name__ == '__main__':
153 unittest.main()156 for series in ['trusty', 'xenial', 'bionic']:
157 TestDeployment.series = series
158 unittest.main()

Subscribers

People subscribed via source and target branches