Merge lp:~gz/juju-ci-tools/maas_spacelessness into lp:juju-ci-tools

Proposed by Martin Packman
Status: Merged
Merged at revision: 1681
Proposed branch: lp:~gz/juju-ci-tools/maas_spacelessness
Merge into: lp:juju-ci-tools
Diff against target: 48 lines (+22/-1)
2 files modified
jujupy.py (+5/-1)
tests/test_jujupy.py (+17/-0)
To merge this branch: bzr merge lp:~gz/juju-ci-tools/maas_spacelessness
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+309148@code.launchpad.net

Description of the change

New environment variable to disable use of space constraint

Our 2.0 and 2.1 maas environments are now happy with their spaces, but 1.9 is still upset. Both to get those jobs passing again, and to give us an easy way to disable from the jenkins job in the future, this branch adds a new JUJU_CI_SPACELESSNESS environment variable that can be set globally and will disable the space constraint.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Forgot to note, setting the environment variable in the test is fine as the class derives from the base TestCase which isolates os.environ already.

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

Thank you

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'jujupy.py'
2--- jujupy.py 2016-10-24 16:14:59 +0000
3+++ jujupy.py 2016-10-24 17:50:39 +0000
4@@ -1560,11 +1560,15 @@
5 args = e_arg + args
6 self.juju('deployer', args, self.env.needs_sudo(), include_e=False)
7
8+ @staticmethod
9+ def _maas_spaces_enabled():
10+ return not os.environ.get("JUJU_CI_SPACELESSNESS")
11+
12 def _get_substrate_constraints(self):
13 if self.env.joyent:
14 # Only accept kvm packages by requiring >1 cpu core, see lp:1446264
15 return 'mem=2G cpu-cores=1'
16- elif self.env.maas:
17+ elif self.env.maas and self._maas_spaces_enabled():
18 # For now only maas support spaces in a meaningful way.
19 return 'mem=2G spaces={}'.format(','.join(
20 '^' + space for space in sorted(self.excluded_spaces)))
21
22=== modified file 'tests/test_jujupy.py'
23--- tests/test_jujupy.py 2016-10-24 16:14:59 +0000
24+++ tests/test_jujupy.py 2016-10-24 17:50:39 +0000
25@@ -801,6 +801,23 @@
26 '--agent-version', '2.0'),
27 include_e=False)
28
29+ def test_bootstrap_maas_spaceless(self):
30+ # Disable space constraint with environment variable
31+ os.environ['JUJU_CI_SPACELESSNESS'] = "1"
32+ env = JujuData('maas', {'type': 'foo', 'region': 'asdf'})
33+ with patch.object(EnvJujuClient, 'juju') as mock:
34+ client = EnvJujuClient(env, '2.0-zeta1', None)
35+ with patch.object(client.env, 'maas', lambda: True):
36+ with observable_temp_file() as config_file:
37+ client.bootstrap()
38+ mock.assert_called_with(
39+ 'bootstrap', (
40+ '--constraints', 'mem=2G'
41+ 'foo/asdf', 'maas',
42+ '--config', config_file.name, '--default-model', 'maas',
43+ '--agent-version', '2.0'),
44+ include_e=False)
45+
46 def test_bootstrap_joyent(self):
47 env = JujuData('joyent', {
48 'type': 'joyent', 'sdc-url': 'https://foo.api.joyentcloud.com'})

Subscribers

People subscribed via source and target branches