Merge lp:~jog/juju-ci-tools/centos_deploy_stack into lp:juju-ci-tools

Proposed by John George on 2015-10-21
Status: Merged
Approved by: Martin Packman on 2015-10-21
Approved revision: 1126
Merged at revision: 1125
Proposed branch: lp:~jog/juju-ci-tools/centos_deploy_stack
Merge into: lp:juju-ci-tools
Diff against target: 112 lines (+55/-6)
2 files modified
deploy_stack.py (+10/-6)
tests/test_deploy_stack.py (+45/-0)
To merge this branch: bzr merge lp:~jog/juju-ci-tools/centos_deploy_stack
Reviewer Review Type Date Requested Status
Martin Packman (community) 2015-10-21 Approve on 2015-10-21
Review via email: mp+275135@code.launchpad.net

Description of the Change

When deploying centos charms:
1. Set the series for the bootstrap machine back to trusty.
2. Avoid calling assess_juju_run.
3. Add constraints to request appropriate nodes from MAAS.

To post a comment you must log in.
Martin Packman (gz) wrote :

Looks good, a few comments inline.

review: Approve
1126. By John George on 2015-10-21

Adjust mocks and MAAS constraint tag names.

John George (jog) wrote :

I actually had to assign PCI slots to NICs out of order. It's about MAAS being cabled to the first device that's discovered by CentOS and how those NICs are assigned to the network bridges defined on the hypervisor host machine. Added a 'MAAS_NIC_1' tag to our MAAS 1.8 and 1.9 environments.

I updated skip_juju_run, so it's set by passing a tuple to charm_prefix.startswith()

Adjusted mocks for test_deploy_dummy_stack_sets_centos_constraints()

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'deploy_stack.py'
2--- deploy_stack.py 2015-09-23 13:30:52 +0000
3+++ deploy_stack.py 2015-10-21 17:28:25 +0000
4@@ -70,6 +70,10 @@
5 def deploy_dummy_stack(client, charm_prefix):
6 """"Deploy a dummy stack in the specified environment.
7 """
8+ # Centos requires specific machine configuration (i.e. network device
9+ # order).
10+ if charm_prefix.startswith("local:centos") and client.env.maas:
11+ client.juju('set-constraints', ('tags=MAAS_NIC_1',))
12 client.deploy(charm_prefix + 'dummy-source')
13 token = get_random_string()
14 client.juju('set', ('dummy-source', 'token=%s' % token))
15@@ -339,9 +343,9 @@
16 if series is None:
17 series = 'precise'
18 charm_prefix = 'local:{}/'.format(series)
19- # Don't need windows state server to test windows charms, trusty is faster.
20- if series.startswith("win"):
21- logging.info('Setting default series to trusty for windows deploy.')
22+ # Don't need windows or centos state servers.
23+ if series.startswith("win") or series.startswith("centos"):
24+ logging.info('Setting default series to trusty for win and centos.')
25 series = 'trusty'
26 return _deploy_job(args.temp_env_name, args.env, args.upgrade,
27 charm_prefix, args.bootstrap_host, args.machine,
28@@ -544,12 +548,12 @@
29 manager = nested()
30 with manager:
31 deploy_dummy_stack(client, charm_prefix)
32- is_windows_charm = charm_prefix.startswith("local:win")
33- if not is_windows_charm:
34+ skip_juju_run = charm_prefix.startswith(("local:centos", "local:win"))
35+ if not skip_juju_run:
36 assess_juju_run(client)
37 if upgrade:
38 client.juju('status', ())
39- assess_upgrade(client, juju_path, skip_juju_run=is_windows_charm)
40+ assess_upgrade(client, juju_path, skip_juju_run)
41
42
43 def safe_print_status(client):
44
45=== modified file 'tests/test_deploy_stack.py'
46--- tests/test_deploy_stack.py 2015-10-14 19:51:57 +0000
47+++ tests/test_deploy_stack.py 2015-10-21 17:28:25 +0000
48@@ -25,6 +25,7 @@
49 copy_local_logs,
50 copy_remote_logs,
51 deploy_dummy_stack,
52+ deploy_job,
53 _deploy_job,
54 deploy_job_parse_args,
55 destroy_environment,
56@@ -519,6 +520,20 @@
57
58 class TestDeployDummyStack(FakeHomeTestCase):
59
60+ @patch('deploy_stack.check_token')
61+ def test_deploy_dummy_stack_sets_centos_constraints(self, ct_mock):
62+ env = SimpleEnvironment('foo', {'type': 'maas'})
63+ client = EnvJujuClient(env, None, '/foo/juju')
64+ with patch('subprocess.check_call', autospec=True) as cc_mock:
65+ with patch.object(EnvJujuClient, 'wait_for_started'):
66+ with patch('deploy_stack.get_random_string',
67+ return_value='fake-token', autospec=True):
68+ deploy_dummy_stack(client, 'local:centos/foo')
69+ assert_juju_call(self, cc_mock, client,
70+ ('juju', '--show-log', 'set-constraints', '-e', 'foo',
71+ 'tags=MAAS_NIC_1'), 0)
72+ self.assertEqual(ct_mock.call_count, 1)
73+
74 def test_deploy_dummy_stack(self):
75 env = SimpleEnvironment('foo', {'type': 'nonlocal'})
76 client = EnvJujuClient(env, None, '/foo/juju')
77@@ -632,6 +647,36 @@
78 'foo', client, None, None, None, None, None, None, None, None,
79 permanent=False, region='region-foo')
80
81+ def test_deploy_job_changes_series_with_win(self):
82+ args = Namespace(
83+ series='windows', temp_env_name=None, env=None, upgrade=None,
84+ charm_prefix=None, bootstrap_host=None, machine=None, logs=None,
85+ debug=None, juju_bin=None, agent_url=None, agent_stream=None,
86+ keep_env=None, upload_tools=None, with_chaos=None, jes=None,
87+ pre_destroy=None, region=None, verbose=None)
88+ with patch('deploy_stack.deploy_job_parse_args', return_value=args,
89+ autospec=True):
90+ with patch('deploy_stack._deploy_job', autospec=True) as ds_mock:
91+ deploy_job()
92+ call_args = ds_mock.call_args[0]
93+ self.assertEqual(call_args[3], 'local:windows/')
94+ self.assertEqual(call_args[6], 'trusty')
95+
96+ def test_deploy_job_changes_series_with_centos(self):
97+ args = Namespace(
98+ series='centos', temp_env_name=None, env=None, upgrade=None,
99+ charm_prefix=None, bootstrap_host=None, machine=None, logs=None,
100+ debug=None, juju_bin=None, agent_url=None, agent_stream=None,
101+ keep_env=None, upload_tools=None, with_chaos=None, jes=None,
102+ pre_destroy=None, region=None, verbose=None)
103+ with patch('deploy_stack.deploy_job_parse_args', return_value=args,
104+ autospec=True):
105+ with patch('deploy_stack._deploy_job', autospec=True) as ds_mock:
106+ deploy_job()
107+ call_args = ds_mock.call_args[0]
108+ self.assertEqual(call_args[3], 'local:centos/')
109+ self.assertEqual(call_args[6], 'trusty')
110+
111
112 class TestTestUpgrade(FakeHomeTestCase):
113

Subscribers

People subscribed via source and target branches