Merge lp:~abentley/juju-ci-tools/fake-series into lp:juju-ci-tools

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 1941
Proposed branch: lp:~abentley/juju-ci-tools/fake-series
Merge into: lp:juju-ci-tools
Diff against target: 74 lines (+27/-2)
3 files modified
jujupy/fake.py (+6/-2)
jujupy/tests/test_fake.py (+14/-0)
tests/test_assess_mixed_images.py (+7/-0)
To merge this branch: bzr merge lp:~abentley/juju-ci-tools/fake-series
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+320260@code.launchpad.net

Commit message

Add dummy series to machines in fake.

Description of the change

This branch adds a 'series' field to FakeBackend's status output.

This is useful to Hammer Time, because it checks the series of a machine when deciding which operations it can perform. (Windows machines don't have iptables, for example.)

At this stage, we don't need the field to be configurable-- we just need it to exist and not start with "win". Should that change, I envision storing a dict of machine_id_to_series, similar to FakeEnvironmentState.machine_host_names.

To post a comment you must log in.
1942. By Aaron Bentley

Remove machine_series partial implementation.

Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you. And Thank your for using angsty to be clear that we put that series there.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'jujupy/fake.py'
2--- jujupy/fake.py 2017-03-16 19:36:04 +0000
3+++ jujupy/fake.py 2017-03-17 20:43:28 +0000
4@@ -249,7 +249,10 @@
5 def get_status_dict(self):
6 machines = {}
7 for machine_id in self.machines:
8- machine_dict = {'juju-status': {'current': 'idle'}}
9+ machine_dict = {
10+ 'juju-status': {'current': 'idle'},
11+ 'series': 'angsty',
12+ }
13 hostname = self.machine_host_names.get(machine_id)
14 machine_dict['instance-id'] = machine_id
15 if hostname is not None:
16@@ -258,7 +261,8 @@
17 if machine_id in self.state_servers:
18 machine_dict['controller-member-status'] = 'has-vote'
19 for host, containers in self.containers.items():
20- container_dict = dict((c, {}) for c in containers)
21+ container_dict = dict((c, {'series': 'angsty'})
22+ for c in containers)
23 for container, subdict in container_dict.items():
24 subdict.update({'juju-status': {'current': 'idle'}})
25 dns_name = self.machine_host_names.get(container)
26
27=== added file 'jujupy/tests/test_fake.py'
28--- jujupy/tests/test_fake.py 1970-01-01 00:00:00 +0000
29+++ jujupy/tests/test_fake.py 2017-03-17 20:43:28 +0000
30@@ -0,0 +1,14 @@
31+from jujupy.fake import FakeEnvironmentState
32+from tests import TestCase
33+
34+
35+class TestEnvironmentState(TestCase):
36+
37+ def test_get_status_dict_series(self):
38+ state = FakeEnvironmentState()
39+ state.add_container('lxd')
40+ status_dict = state.get_status_dict()
41+ machine_0 = status_dict['machines']['0']
42+ self.assertEqual(machine_0['series'], 'angsty')
43+ lxd_0 = machine_0['containers']['0/lxd/0']
44+ self.assertEqual(lxd_0['series'], 'angsty')
45
46=== modified file 'tests/test_assess_mixed_images.py'
47--- tests/test_assess_mixed_images.py 2017-02-25 06:09:40 +0000
48+++ tests/test_assess_mixed_images.py 2017-03-17 20:43:28 +0000
49@@ -85,6 +85,11 @@
50 mock_client = fake_juju_client()
51 mock_client.bootstrap()
52 assess_mixed_images(mock_client)
53+ # The series are 'angsty' instead of 'centos7' and 'trusty', because
54+ # local_charm_path drops the series information. When JUJU_REPOSITORY
55+ # is not defined, there is no way to know what series is intended from
56+ # path. In real-world use, the series is determined from the charm
57+ # metadata, but these tests don't have access to it.
58 expected = {
59 'model': {'name': 'name'},
60 'machines': {
61@@ -92,11 +97,13 @@
62 'dns-name': '0.example.com',
63 'instance-id': '0',
64 'juju-status': {'current': 'idle'},
65+ 'series': 'angsty',
66 },
67 '1': {
68 'dns-name': '1.example.com',
69 'instance-id': '1',
70 'juju-status': {'current': 'idle'},
71+ 'series': 'angsty',
72 },
73 },
74 'applications': {

Subscribers

People subscribed via source and target branches