Merge lp:~nskaggs/juju-ci-tools/ci-jimm into lp:juju-ci-tools

Proposed by Nicholas Skaggs on 2017-03-29
Status: Needs review
Proposed branch: lp:~nskaggs/juju-ci-tools/ci-jimm
Merge into: lp:juju-ci-tools
Diff against target: 208 lines (+68/-13) (has conflicts)
3 files modified
deploy_stack.py (+57/-10)
jujupy/client.py (+10/-3)
tests/test_deploy_stack.py (+1/-0)
Text conflict in deploy_stack.py
To merge this branch: bzr merge lp:~nskaggs/juju-ci-tools/ci-jimm
Reviewer Review Type Date Requested Status
Seman (community) 2017-03-29 Needs Information on 2017-03-29
Review via email: mp+321356@code.launchpad.net

Description of the change

This adds the ability to test an standing up a JIMM controller using our unstable juju. The standard fare of deploy tests are then run against the resulting deployment. This utilizes our elastic IP found in the us-west-2 region on aws, and thus is locked into running against that region. You'll also need ec2 and sso credentials to run this.

To post a comment you must log in.
lp:~nskaggs/juju-ci-tools/ci-jimm updated on 2017-03-29
1942. By Nicholas Skaggs on 2017-03-29

fix public controller

1943. By Nicholas Skaggs on 2017-03-29

another try

Seman (sseman) wrote :

See in-line comments. Also, I don't think this passes make test by looking at the code.

review: Needs Information
lp:~nskaggs/juju-ci-tools/ci-jimm updated on 2017-04-06
1944. By Nicholas Skaggs on 2017-04-06

flake8

Unmerged revisions

1944. By Nicholas Skaggs on 2017-04-06

flake8

1943. By Nicholas Skaggs on 2017-03-29

another try

1942. By Nicholas Skaggs on 2017-03-29

fix public controller

1941. By Nicholas Skaggs on 2017-03-29

restore run-deploy-job.bash

1940. By Nicholas Skaggs on 2017-03-29

check for artifact dir to prevent makedirs error

1939. By Nicholas Skaggs on 2017-03-29

Ignore client status for public controller

1938. By Nicholas Skaggs on 2017-03-29

restore lost changes

1937. By Nicholas Skaggs on 2017-03-29

merge trunk

1936. By Nicholas Skaggs on 2017-03-23

Merge trunk

1935. By Nicholas Skaggs on 2017-03-23

restore status prints

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 2017-04-05 23:07:51 +0000
3+++ deploy_stack.py 2017-04-06 18:12:10 +0000
4@@ -8,17 +8,28 @@
5 from contextlib import nested
6 except ImportError:
7 from contextlib import ExitStack as nested
8+<<<<<<< TREE
9+=======
10+
11+
12+import errno
13+>>>>>>> MERGE-SOURCE
14 import glob
15+import json
16 import logging
17 import os
18 import random
19 import re
20+import shutil
21 import string
22 import subprocess
23 import sys
24 import time
25+<<<<<<< TREE
26 import yaml
27 import shutil
28+=======
29+>>>>>>> MERGE-SOURCE
30
31 from chaos import background_chaos
32 from jujucharm import (
33@@ -459,6 +470,8 @@
34 'Host with a controller to use. If supplied, SSO_EMAIL and'
35 ' SSO_PASSWORD environment variables will be used for oauth'
36 ' authentication.'))
37+ parser.add_argument(
38+ '--controller-host-dns', help=('Set DNS for controller host.'))
39 parser.add_argument('--use-charmstore', action='store_true',
40 help='Deploy dummy charms from the charmstore.')
41 return parser.parse_args(argv)
42@@ -509,13 +522,15 @@
43 client.env.juju_home = old_home
44
45
46-def make_controller_strategy(client, tear_down_client, controller_host):
47+def make_controller_strategy(client, tear_down_client,
48+ controller_host, controller_host_dns):
49 if controller_host is None:
50 return CreateController(client, tear_down_client)
51 else:
52 return PublicController(
53 controller_host, os.environ['SSO_EMAIL'],
54- os.environ['SSO_PASSWORD'], client, tear_down_client)
55+ os.environ['SSO_PASSWORD'], client,
56+ tear_down_client, controller_host_dns)
57
58
59 def error_if_unclean(unclean_resources):
60@@ -576,12 +591,13 @@
61 The user registers with the controller, and adds the initial model.
62 """
63 def __init__(self, controller_host, email, password, client,
64- tear_down_client):
65+ tear_down_client, controller_host_dns):
66 self.controller_host = controller_host
67 self.email = email
68 self.password = password
69 self.client = client
70 self.tear_down_client = tear_down_client
71+ self.controller_host_dns = controller_host_dns
72
73 def prepare(self):
74 """Prepare by destroying the model and unregistering if possible."""
75@@ -594,8 +610,27 @@
76
77 def create_initial_model(self, upload_tools, series, boot_kwargs):
78 """Register controller and add model."""
79- self.client.register_host(
80- self.controller_host, self.email, self.password)
81+ if self.controller_host_dns is not None:
82+ self.client.bootstrap(upload_tools=upload_tools,
83+ bootstrap_series=series,
84+ controller_host=self.controller_host,
85+ **boot_kwargs)
86+ # Register an external user before exile.
87+ self.client.grant('juju-qa-bot@external', 'superuser')
88+ # Exile the controller by associating the dns ip.
89+ instance_id = self.client.get_controller_client(
90+ ).get_status().get_instance_id('0')
91+ # Controller is now exiled. No client will work.
92+ # register the client with the dns name to make it work again
93+ subprocess.check_call(
94+ ['euca-associate-address', '-i', instance_id,
95+ self.controller_host_dns])
96+ # Unregister the controller from the old name
97+ self.client.juju('unregister',
98+ ('--yes', self.client.env.environment),
99+ include_e=False)
100+ self.client.register_host(self.controller_host, self.email,
101+ self.password)
102 self.client.env.controller.explicit_region = True
103 self.client.add_model(self.client.env)
104
105@@ -913,7 +948,10 @@
106 yield
107 except:
108 if self.has_controller:
109- safe_print_status(self.client)
110+ if self.controller_strategy.controller_host_dns:
111+ logging.info("Public controller, not calling status.")
112+ else:
113+ safe_print_status(self.client)
114 else:
115 logging.info("Client lost controller, not calling status.")
116 raise
117@@ -977,7 +1015,11 @@
118 runtime_config = None
119 artifacts_dir = os.path.join(self.log_dir,
120 client.env.environment)
121- os.makedirs(artifacts_dir)
122+ try:
123+ os.makedirs(artifacts_dir)
124+ except OSError as exception:
125+ if exception.errno != errno.EEXIST:
126+ raise
127 dump_env_logs_known_hosts(
128 client, artifacts_dir, runtime_config, known_hosts)
129
130@@ -1019,8 +1061,12 @@
131 with self.runtime_context(machines):
132 self.client.list_controllers()
133 self.client.list_models()
134- for m_client in self.client.iter_model_clients():
135- m_client.show_status()
136+ if self.controller_strategy.controller_host_dns:
137+ logging.info("Public controller, not calling status.")
138+ self.client.show_status()
139+ else:
140+ for m_client in self.client.iter_model_clients():
141+ m_client.show_status()
142 yield machines
143 except LoggedException:
144 if self.logged_exception_exit:
145@@ -1098,7 +1144,8 @@
146 client.enable_jes()
147 jes_enabled = client.is_jes_enabled()
148 controller_strategy = make_controller_strategy(client, client,
149- args.controller_host)
150+ args.controller_host,
151+ args.controller_host_dns)
152 bs_manager = BootstrapManager(
153 args.temp_env_name, client, client, args.bootstrap_host, args.machine,
154 series, args.agent_url, args.agent_stream, args.region, args.logs,
155
156=== modified file 'jujupy/client.py'
157--- jujupy/client.py 2017-04-05 23:07:51 +0000
158+++ jujupy/client.py 2017-04-06 18:12:10 +0000
159@@ -1852,7 +1852,7 @@
160 def get_bootstrap_args(
161 self, upload_tools, config_filename, bootstrap_series=None,
162 credential=None, auto_upgrade=False, metadata_source=None,
163- no_gui=False, agent_version=None):
164+ no_gui=False, agent_version=None, controller_host=None):
165 """Return the bootstrap arguments for the substrate."""
166 constraints = self._get_substrate_constraints()
167 cloud_region = self.get_cloud_region(self.env.get_cloud(),
168@@ -1882,6 +1882,13 @@
169 args.append('--auto-upgrade')
170 if self.env.bootstrap_to is not None:
171 args.extend(['--to', self.env.bootstrap_to])
172+ if controller_host:
173+ args.extend(['--config',
174+ 'autocert-dns-name={}'.format(controller_host)])
175+ args.extend(['--config',
176+ 'identity-url=https://api.jujucharms.com/identity'])
177+ args.extend(['--config',
178+ 'autocert-url=https://acme-staging.api.letsencrypt.org/directory'])
179 if no_gui:
180 args.append('--no-gui')
181 return tuple(args)
182@@ -1954,13 +1961,13 @@
183
184 def bootstrap(self, upload_tools=False, bootstrap_series=None,
185 credential=None, auto_upgrade=False, metadata_source=None,
186- no_gui=False, agent_version=None):
187+ no_gui=False, agent_version=None, controller_host=None):
188 """Bootstrap a controller."""
189 self._check_bootstrap()
190 with self._bootstrap_config() as config_filename:
191 args = self.get_bootstrap_args(
192 upload_tools, config_filename, bootstrap_series, credential,
193- auto_upgrade, metadata_source, no_gui, agent_version)
194+ auto_upgrade, metadata_source, no_gui, agent_version, controller_host)
195 self.update_user_name()
196 retvar, ct = self.juju('bootstrap', args, include_e=False)
197 ct.actual_completion()
198
199=== modified file 'tests/test_deploy_stack.py'
200--- tests/test_deploy_stack.py 2017-04-05 23:07:51 +0000
201+++ tests/test_deploy_stack.py 2017-04-06 18:12:10 +0000
202@@ -2656,6 +2656,7 @@
203 to=None,
204 deadline=None,
205 controller_host=None,
206+ controller_host_dns=None,
207 use_charmstore=False,
208 ))
209

Subscribers

People subscribed via source and target branches