Merge lp:~abentley/juju-ci-tools/industrial-agent-stream into lp:juju-ci-tools

Proposed by Aaron Bentley
Status: Needs review
Proposed branch: lp:~abentley/juju-ci-tools/industrial-agent-stream
Merge into: lp:juju-ci-tools
Diff against target: 476 lines (+109/-50)
3 files modified
industrial_test.py (+26/-14)
run-reliability-test.bash (+4/-2)
tests/test_industrial_test.py (+79/-34)
To merge this branch: bzr merge lp:~abentley/juju-ci-tools/industrial-agent-stream
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+282668@code.launchpad.net

Commit message

Add --agent-stream to industrial_test.

Description of the change

Add --agent-stream support to industrial_test.

This allows running industrial tests of arbitrary builds without the candidate urls.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

thank you.

review: Approve (code)

Unmerged revisions

1244. By Aaron Bentley

Fix lint.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'industrial_test.py'
--- industrial_test.py 2016-01-13 21:31:55 +0000
+++ industrial_test.py 2016-01-14 21:01:47 +0000
@@ -72,6 +72,7 @@
72 :ivar new_juju_path: Path to the non-system juju.72 :ivar new_juju_path: Path to the non-system juju.
73 :ivar stages: A list of StageAttempts.73 :ivar stages: A list of StageAttempts.
74 :ivar attempt_count: The number of attempts needed for each stage.74 :ivar attempt_count: The number of attempts needed for each stage.
75 :ivar agent_stream: The agent stream to use for testing.
75 """76 """
7677
77 @classmethod78 @classmethod
@@ -80,7 +81,8 @@
80 stages = cls.get_stages(suite, config)81 stages = cls.get_stages(suite, config)
81 return cls(args.env, args.new_juju_path,82 return cls(args.env, args.new_juju_path,
82 stages, args.log_dir, args.attempts, args.attempts * 2,83 stages, args.log_dir, args.attempts, args.attempts * 2,
83 args.new_agent_url, args.debug, args.old_stable)84 args.new_agent_url, args.debug, args.old_stable,
85 args.agent_stream)
8486
85 @staticmethod87 @staticmethod
86 def get_stages(suite, config):88 def get_stages(suite, config):
@@ -88,7 +90,7 @@
8890
89 def __init__(self, env, new_juju_path, stages, log_dir, attempt_count=2,91 def __init__(self, env, new_juju_path, stages, log_dir, attempt_count=2,
90 max_attempts=1, new_agent_url=None, debug=False,92 max_attempts=1, new_agent_url=None, debug=False,
91 really_old_path=None):93 really_old_path=None, agent_stream=None):
92 self.env = env94 self.env = env
93 self.really_old_path = really_old_path95 self.really_old_path = really_old_path
94 self.new_juju_path = new_juju_path96 self.new_juju_path = new_juju_path
@@ -98,6 +100,7 @@
98 self.max_attempts = max_attempts100 self.max_attempts = max_attempts
99 self.debug = debug101 self.debug = debug
100 self.log_parent_dir = log_dir102 self.log_parent_dir = log_dir
103 self.agent_stream = agent_stream
101104
102 def make_results(self):105 def make_results(self):
103 """Return a results list for use in run_tests."""106 """Return a results list for use in run_tests."""
@@ -150,7 +153,8 @@
150 paths = [self.really_old_path, stable_path, self.new_juju_path]153 paths = [self.really_old_path, stable_path, self.new_juju_path]
151 upgrade_sequence = [p for p in paths if p is not None]154 upgrade_sequence = [p for p in paths if p is not None]
152 stage_attempts = [self.stages.factory(upgrade_sequence,155 stage_attempts = [self.stages.factory(upgrade_sequence,
153 self.log_parent_dir)]156 self.log_parent_dir,
157 self.agent_stream)]
154 return IndustrialTest.from_args(self.env, self.new_juju_path,158 return IndustrialTest.from_args(self.env, self.new_juju_path,
155 stage_attempts, self.new_agent_url,159 stage_attempts, self.new_agent_url,
156 self.debug)160 self.debug)
@@ -273,7 +277,7 @@
273 """277 """
274278
275 @classmethod279 @classmethod
276 def factory(cls, upgrade_sequence):280 def factory(cls, upgrade_sequence, agent_stream):
277 return cls()281 return cls()
278282
279 @staticmethod283 @staticmethod
@@ -428,7 +432,7 @@
428 return dict([cls.prepare_upgrade.as_tuple()])432 return dict([cls.prepare_upgrade.as_tuple()])
429433
430 @classmethod434 @classmethod
431 def factory(cls, upgrade_sequence):435 def factory(cls, upgrade_sequence, agent_stream):
432 if len(upgrade_sequence) < 2:436 if len(upgrade_sequence) < 2:
433 raise ValueError('Not enough paths for upgrade.')437 raise ValueError('Not enough paths for upgrade.')
434 bootstrap_paths = dict(438 bootstrap_paths = dict(
@@ -821,14 +825,15 @@
821 result.update(DestroyEnvironmentAttempt.get_test_info())825 result.update(DestroyEnvironmentAttempt.get_test_info())
822 return result826 return result
823827
824 def factory(self, upgrade_sequence, log_dir):828 def factory(self, upgrade_sequence, log_dir, agent_stream):
825 """Emit an AttemptSuite.829 """Emit an AttemptSuite.
826830
827 :param upgrade_sequence: The sequence of jujus to upgrade, for831 :param upgrade_sequence: The sequence of jujus to upgrade, for
828 UpgradeJujuAttempt.832 UpgradeJujuAttempt.
829 :param log_dir: Directory to store logs and other artifacts in.833 :param log_dir: Directory to store logs and other artifacts in.
834 :param agent_stream: The agent stream to use for testing.
830 """835 """
831 return AttemptSuite(self, upgrade_sequence, log_dir)836 return AttemptSuite(self, upgrade_sequence, log_dir, agent_stream)
832837
833838
834class AttemptSuite(SteppedStageAttempt):839class AttemptSuite(SteppedStageAttempt):
@@ -839,12 +844,14 @@
839 :ivar upgrade_sequence: The sequence of jujus to upgrade, for844 :ivar upgrade_sequence: The sequence of jujus to upgrade, for
840 UpgradeJujuAttempt.845 UpgradeJujuAttempt.
841 :ivar log_dir: Directory to store logs and other artifacts in.846 :ivar log_dir: Directory to store logs and other artifacts in.
847 :ivar agent_stream: The agent stream to use for testing.
842 """848 """
843849
844 def __init__(self, attempt_list, upgrade_sequence, log_dir):850 def __init__(self, attempt_list, upgrade_sequence, log_dir, agent_stream):
845 self.attempt_list = attempt_list851 self.attempt_list = attempt_list
846 self.upgrade_sequence = upgrade_sequence852 self.upgrade_sequence = upgrade_sequence
847 self.log_dir = log_dir853 self.log_dir = log_dir
854 self.agent_stream = agent_stream
848855
849 def get_test_info(self):856 def get_test_info(self):
850 """Describe the tests provided by this Stage."""857 """Describe the tests provided by this Stage."""
@@ -862,15 +869,16 @@
862 The actual generator is _iter_bs_manager_steps, to simplify testing.869 The actual generator is _iter_bs_manager_steps, to simplify testing.
863 """870 """
864 bootstrap_attempt = self.attempt_list.bootstrap_attempt.factory(871 bootstrap_attempt = self.attempt_list.bootstrap_attempt.factory(
865 self.upgrade_sequence)872 self.upgrade_sequence, self.agent_stream)
866 bs_client = bootstrap_attempt.get_bootstrap_client(client)873 bs_client = bootstrap_attempt.get_bootstrap_client(client)
867 bs_jes_enabled = bs_client.is_jes_enabled()874 bs_jes_enabled = bs_client.is_jes_enabled()
868 jes_enabled = client.is_jes_enabled()875 jes_enabled = client.is_jes_enabled()
869 bs_manager = BootstrapManager(876 bs_manager = BootstrapManager(
870 client.env.environment, bs_client, bs_client,877 client.env.environment, bs_client, bs_client,
871 bootstrap_host=None,878 bootstrap_host=None,
872 machines=[], series=None, agent_url=None, agent_stream=None,879 machines=[], series=None, agent_url=None,
873 region=None, log_dir=make_log_dir(self.log_dir), keep_env=True,880 agent_stream=self.agent_stream, region=None,
881 log_dir=make_log_dir(self.log_dir), keep_env=True,
874 permanent=jes_enabled, jes_enabled=bs_jes_enabled)882 permanent=jes_enabled, jes_enabled=bs_jes_enabled)
875 return self._iter_bs_manager_steps(bs_manager, client,883 return self._iter_bs_manager_steps(bs_manager, client,
876 bootstrap_attempt, jes_enabled)884 bootstrap_attempt, jes_enabled)
@@ -890,8 +898,9 @@
890 bs_manager.client = client898 bs_manager.client = client
891 bs_manager.tear_down_client = client899 bs_manager.tear_down_client = client
892 bs_manager.jes_enabled = jes_enabled900 bs_manager.jes_enabled = jes_enabled
893 attempts = [a.factory(self.upgrade_sequence) for a in901 attempts = [
894 self.attempt_list.attempt_list]902 a.factory(self.upgrade_sequence, self.agent_stream)
903 for a in self.attempt_list.attempt_list]
895 yield self.attempt_list.prepare_suite.as_result(True)904 yield self.attempt_list.prepare_suite.as_result(True)
896 for attempt in attempts:905 for attempt in attempts:
897 for result in attempt.iter_steps(client):906 for result in attempt.iter_steps(client):
@@ -958,6 +967,8 @@
958 parser.add_argument('--new-agent-url')967 parser.add_argument('--new-agent-url')
959 parser.add_argument('--single', action='store_true')968 parser.add_argument('--single', action='store_true')
960 parser.add_argument('--debug', action='store_true', default=False)969 parser.add_argument('--debug', action='store_true', default=False)
970 parser.add_argument('--agent-stream',
971 help='Agent stream to use for tests.')
961 parser.add_argument(972 parser.add_argument(
962 '--old-stable', help='Path to a version of juju that stable can'973 '--old-stable', help='Path to a version of juju that stable can'
963 ' upgrade from.')974 ' upgrade from.')
@@ -981,7 +992,8 @@
981 for suite in args.suite:992 for suite in args.suite:
982 factory = MultiIndustrialTest.get_stages(suite, env.config)993 factory = MultiIndustrialTest.get_stages(suite, env.config)
983 upgrade_sequence = [upgrade_client.full_path, client.full_path]994 upgrade_sequence = [upgrade_client.full_path, client.full_path]
984 suite = factory.factory(upgrade_sequence, args.log_dir)995 suite = factory.factory(upgrade_sequence, args.log_dir,
996 args.agent_stream)
985 steps_iter = suite.iter_steps(client)997 steps_iter = suite.iter_steps(client)
986 for step in steps_iter:998 for step in steps_iter:
987 print(step)999 print(step)
9881000
=== modified file 'run-reliability-test.bash'
--- run-reliability-test.bash 2015-03-02 21:22:28 +0000
+++ run-reliability-test.bash 2016-01-14 21:01:47 +0000
@@ -15,11 +15,13 @@
15fi15fi
16set -x16set -x
17# Delete all files in $WORKSPACE, but no error if empty.17# Delete all files in $WORKSPACE, but no error if empty.
18find $WORKSPACE -type f -delete18find $WORKSPACE -mindepth 1 -delete
19logs=$WORKSPACE/logs
20mkdir $logs
19$SCRIPTS/write_industrial_test_metadata.py $new_juju_dir/buildvars.json \21$SCRIPTS/write_industrial_test_metadata.py $new_juju_dir/buildvars.json \
20 $environment metadata.json22 $environment metadata.json
21s3cmd -c $s3cfg put metadata.json $s3base-metadata.json23s3cmd -c $s3cfg put metadata.json $s3base-metadata.json
22timeout -sINT -k 10m 1d $SCRIPTS/industrial_test.py $environment $new_juju \24timeout -sINT -k 10m 1d $SCRIPTS/industrial_test.py $environment $new_juju \
23 --old-stable $old_stable_juju $suite --attempts $attempts \25 $logs --old-stable $old_stable_juju $suite --attempts $attempts \
24 --json-file results.json $extra_args26 --json-file results.json $extra_args
25s3cmd -c $s3cfg put results.json $s3base-results.json27s3cmd -c $s3cfg put results.json $s3base-results.json
2628
=== modified file 'tests/test_industrial_test.py'
--- tests/test_industrial_test.py 2016-01-13 21:33:11 +0000
+++ tests/test_industrial_test.py 2016-01-14 21:01:47 +0000
@@ -164,6 +164,7 @@
164 self.assertEqual(args.new_juju_path, 'new-juju')164 self.assertEqual(args.new_juju_path, 'new-juju')
165 self.assertEqual(args.log_dir, 'log-dir')165 self.assertEqual(args.log_dir, 'log-dir')
166 self.assertEqual(args.suite, [QUICK])166 self.assertEqual(args.suite, [QUICK])
167 self.assertIs(args.agent_stream, None)
167168
168 def test_parse_args_attempts(self):169 def test_parse_args_attempts(self):
169 args = parse_args(['rai', 'new-juju', QUICK, 'log-dir'])170 args = parse_args(['rai', 'new-juju', QUICK, 'log-dir'])
@@ -221,6 +222,13 @@
221 args = parse_args(['rai', 'new-juju', QUICK, 'log-dir'])222 args = parse_args(['rai', 'new-juju', QUICK, 'log-dir'])
222 self.assertIs(args.old_stable, None)223 self.assertIs(args.old_stable, None)
223224
225 def test_parse_args_agent_stream(self):
226 args = parse_args(['rai', 'new-juju', QUICK, 'log-dir',
227 '--agent-stream', 'asdf'])
228 self.assertEqual(args.agent_stream, 'asdf')
229 args = parse_args(['rai', 'new-juju', QUICK, 'log-dir'])
230 self.assertIs(args.old_stable, None)
231
224232
225class FakeStepAttempt:233class FakeStepAttempt:
226234
@@ -265,7 +273,7 @@
265 normal methods on FakeAttemptClass.273 normal methods on FakeAttemptClass.
266 """274 """
267275
268 def factory(self, upgrade_sequence):276 def factory(self, upgrade_sequence, attempt_stream):
269 return self()277 return self()
270278
271 def __init__(self, title, *result, **kwargs):279 def __init__(self, title, *result, **kwargs):
@@ -301,7 +309,7 @@
301 args = Namespace(309 args = Namespace(
302 env='foo', new_juju_path='new-path', attempts=7, suite=[DENSITY],310 env='foo', new_juju_path='new-path', attempts=7, suite=[DENSITY],
303 log_dir='log-dir', new_agent_url=None, debug=False,311 log_dir='log-dir', new_agent_url=None, debug=False,
304 old_stable=None)312 old_stable=None, agent_stream=None)
305 with temp_env('foo'):313 with temp_env('foo'):
306 mit = MultiIndustrialTest.from_args(args, QUICK)314 mit = MultiIndustrialTest.from_args(args, QUICK)
307 self.assertEqual(mit.env, 'foo')315 self.assertEqual(mit.env, 'foo')
@@ -309,12 +317,13 @@
309 self.assertEqual(mit.attempt_count, 7)317 self.assertEqual(mit.attempt_count, 7)
310 self.assertEqual(mit.max_attempts, 14)318 self.assertEqual(mit.max_attempts, 14)
311 self.assertEqual(mit.log_parent_dir, 'log-dir')319 self.assertEqual(mit.log_parent_dir, 'log-dir')
320 self.assertIs(mit.agent_stream, None)
312 self.assertEqual(321 self.assertEqual(
313 mit.stages, AttemptSuiteFactory([]))322 mit.stages, AttemptSuiteFactory([]))
314 args = Namespace(323 args = Namespace(
315 env='bar', new_juju_path='new-path2', attempts=6, suite=[FULL],324 env='bar', new_juju_path='new-path2', attempts=6, suite=[FULL],
316 log_dir='log-dir2', new_agent_url=None, debug=False,325 log_dir='log-dir2', new_agent_url=None, debug=False,
317 old_stable=None)326 old_stable=None, agent_stream=None)
318 with temp_env('bar'):327 with temp_env('bar'):
319 mit = MultiIndustrialTest.from_args(args, FULL)328 mit = MultiIndustrialTest.from_args(args, FULL)
320 self.assertEqual(mit.env, 'bar')329 self.assertEqual(mit.env, 'bar')
@@ -322,6 +331,7 @@
322 self.assertEqual(mit.attempt_count, 6)331 self.assertEqual(mit.attempt_count, 6)
323 self.assertEqual(mit.max_attempts, 12)332 self.assertEqual(mit.max_attempts, 12)
324 self.assertEqual(mit.log_parent_dir, 'log-dir2')333 self.assertEqual(mit.log_parent_dir, 'log-dir2')
334 self.assertIs(mit.agent_stream, None)
325 self.assertEqual(335 self.assertEqual(
326 mit.stages, AttemptSuiteFactory([336 mit.stages, AttemptSuiteFactory([
327 UpgradeCharmAttempt, DeployManyAttempt,337 UpgradeCharmAttempt, DeployManyAttempt,
@@ -330,7 +340,8 @@
330 def test_from_args_maas(self):340 def test_from_args_maas(self):
331 args = Namespace(341 args = Namespace(
332 env='foo', new_juju_path='new-path', log_dir='log-dir',342 env='foo', new_juju_path='new-path', log_dir='log-dir',
333 attempts=7, new_agent_url=None, debug=False, old_stable=None)343 attempts=7, new_agent_url=None, debug=False, old_stable=None,
344 agent_stream=None)
334 with temp_env('foo', {'type': 'maas'}):345 with temp_env('foo', {'type': 'maas'}):
335 mit = MultiIndustrialTest.from_args(args, DENSITY)346 mit = MultiIndustrialTest.from_args(args, DENSITY)
336 self.assertEqual(347 self.assertEqual(
@@ -339,7 +350,8 @@
339 def test_from_args_debug(self):350 def test_from_args_debug(self):
340 args = Namespace(351 args = Namespace(
341 env='foo', new_juju_path='new-path', log_dir='log-dir',352 env='foo', new_juju_path='new-path', log_dir='log-dir',
342 attempts=7, new_agent_url=None, debug=False, old_stable=None)353 attempts=7, new_agent_url=None, debug=False, old_stable=None,
354 agent_stream=None)
343 with temp_env('foo', {'type': 'maas'}):355 with temp_env('foo', {'type': 'maas'}):
344 mit = MultiIndustrialTest.from_args(args, DENSITY)356 mit = MultiIndustrialTest.from_args(args, DENSITY)
345 self.assertEqual(mit.debug, False)357 self.assertEqual(mit.debug, False)
@@ -351,17 +363,30 @@
351 args = Namespace(363 args = Namespace(
352 env='foo', new_juju_path='new-path', log_dir='log-dir',364 env='foo', new_juju_path='new-path', log_dir='log-dir',
353 attempts=7, new_agent_url=None, debug=False,365 attempts=7, new_agent_url=None, debug=False,
354 old_stable='really-old-path')366 old_stable='really-old-path', agent_stream=None)
355 with temp_env('foo'):367 with temp_env('foo'):
356 mit = MultiIndustrialTest.from_args(args, FULL)368 mit = MultiIndustrialTest.from_args(args, FULL)
357 self.assertEqual(mit.really_old_path, 'really-old-path')369 self.assertEqual(mit.really_old_path, 'really-old-path')
358 args = Namespace(370 args = Namespace(
359 env='bar', new_juju_path='new-path2', log_dir='log-dir',371 env='bar', new_juju_path='new-path2', log_dir='log-dir',
360 attempts=6, new_agent_url=None, debug=False, old_stable=None)372 attempts=6, new_agent_url=None, debug=False, old_stable=None,
373 agent_stream=None)
361 with temp_env('bar'):374 with temp_env('bar'):
362 mit = MultiIndustrialTest.from_args(args, FULL)375 mit = MultiIndustrialTest.from_args(args, FULL)
363 self.assertIs(mit.really_old_path, None)376 self.assertIs(mit.really_old_path, None)
364377
378 def test_from_args_agent_stream(self):
379 args = Namespace(
380 env='foo', new_juju_path='new-path', log_dir='log-dir',
381 attempts=7, new_agent_url=None, debug=False, old_stable=None,
382 agent_stream='foo-stream')
383 with temp_env('foo', {'type': 'maas'}):
384 mit = MultiIndustrialTest.from_args(args, DENSITY)
385 self.assertEqual(mit.debug, False)
386 args.debug = True
387 mit = MultiIndustrialTest.from_args(args, DENSITY)
388 self.assertEqual(mit.agent_stream, 'foo-stream')
389
365 def test_get_stages(self):390 def test_get_stages(self):
366 self.assertEqual(391 self.assertEqual(
367 MultiIndustrialTest.get_stages(QUICK, {'type': 'foo'}),392 MultiIndustrialTest.get_stages(QUICK, {'type': 'foo'}),
@@ -399,7 +424,7 @@
399 args = Namespace(424 args = Namespace(
400 env='foo', new_juju_path='new-path', attempts=7,425 env='foo', new_juju_path='new-path', attempts=7,
401 log_dir='log-dir', new_agent_url=None, debug=False,426 log_dir='log-dir', new_agent_url=None, debug=False,
402 old_stable=None)427 old_stable=None, agent_stream=None)
403 with temp_env('foo'):428 with temp_env('foo'):
404 mit = MultiIndustrialTest.from_args(args, DENSITY)429 mit = MultiIndustrialTest.from_args(args, DENSITY)
405 self.assertEqual(430 self.assertEqual(
@@ -409,7 +434,7 @@
409 args = Namespace(434 args = Namespace(
410 env='foo', new_juju_path='new-path', attempts=7,435 env='foo', new_juju_path='new-path', attempts=7,
411 log_dir='log-dir', new_agent_url=None, debug=False,436 log_dir='log-dir', new_agent_url=None, debug=False,
412 old_stable=None)437 old_stable=None, agent_stream=None)
413 with temp_env('foo'):438 with temp_env('foo'):
414 mit = MultiIndustrialTest.from_args(args, BACKUP)439 mit = MultiIndustrialTest.from_args(args, BACKUP)
415 self.assertEqual(440 self.assertEqual(
@@ -419,7 +444,7 @@
419 args = Namespace(444 args = Namespace(
420 env='foo', new_juju_path='new-path', attempts=7,445 env='foo', new_juju_path='new-path', attempts=7,
421 log_dir='log-dir', new_agent_url='http://example.net',446 log_dir='log-dir', new_agent_url='http://example.net',
422 debug=False, old_stable=None)447 debug=False, old_stable=None, agent_stream=None)
423 with temp_env('foo'):448 with temp_env('foo'):
424 mit = MultiIndustrialTest.from_args(args, suite=QUICK)449 mit = MultiIndustrialTest.from_args(args, suite=QUICK)
425 self.assertEqual(mit.new_agent_url, 'http://example.net')450 self.assertEqual(mit.new_agent_url, 'http://example.net')
@@ -872,7 +897,7 @@
872 FakeAttemptClass('foo', False, True, new_path='bar-path'),897 FakeAttemptClass('foo', False, True, new_path='bar-path'),
873 FakeAttemptClass('bar', True, True, new_path='bar-path')])898 FakeAttemptClass('bar', True, True, new_path='bar-path')])
874 log_dir = use_context(self, temp_dir())899 log_dir = use_context(self, temp_dir())
875 suite = suite_factory.factory([], log_dir)900 suite = suite_factory.factory([], log_dir, None)
876 industrial = IndustrialTest(old_client, new_client, [suite])901 industrial = IndustrialTest(old_client, new_client, [suite])
877 with patch('industrial_test.BootstrapManager',902 with patch('industrial_test.BootstrapManager',
878 fake_bootstrap_manager):903 fake_bootstrap_manager):
@@ -891,7 +916,7 @@
891 suite_factory = AttemptSuiteFactory([916 suite_factory = AttemptSuiteFactory([
892 FakeAttemptClass('foo', True, False, new_path='bar-path'),917 FakeAttemptClass('foo', True, False, new_path='bar-path'),
893 FakeAttemptClass('bar', True, True, new_path='bar-path')])918 FakeAttemptClass('bar', True, True, new_path='bar-path')])
894 suite = suite_factory.factory([], log_dir)919 suite = suite_factory.factory([], log_dir, None)
895 industrial = IndustrialTest(old_client, new_client, [suite])920 industrial = IndustrialTest(old_client, new_client, [suite])
896 with patch('industrial_test.BootstrapManager',921 with patch('industrial_test.BootstrapManager',
897 fake_bootstrap_manager):922 fake_bootstrap_manager):
@@ -909,7 +934,8 @@
909 log_dir = use_context(self, temp_dir())934 log_dir = use_context(self, temp_dir())
910 suite = AttemptSuiteFactory([935 suite = AttemptSuiteFactory([
911 FakeAttemptClass('foo', False, False),936 FakeAttemptClass('foo', False, False),
912 FakeAttemptClass('bar', True, True)]).factory([], log_dir)937 FakeAttemptClass('bar', True, True)]).factory([], log_dir,
938 'foo-stream')
913 industrial = IndustrialTest(old_client, new_client, [suite])939 industrial = IndustrialTest(old_client, new_client, [suite])
914 with patch('industrial_test.BootstrapManager',940 with patch('industrial_test.BootstrapManager',
915 fake_bootstrap_manager):941 fake_bootstrap_manager):
@@ -968,7 +994,7 @@
968 new_client = FakeJujuClient()994 new_client = FakeJujuClient()
969 attempt = FakeStepAttempt.from_result(True, True)995 attempt = FakeStepAttempt.from_result(True, True)
970 log_dir = use_context(self, temp_dir())996 log_dir = use_context(self, temp_dir())
971 suite = AttemptSuiteFactory([attempt]).factory([], log_dir)997 suite = AttemptSuiteFactory([attempt]).factory([], log_dir, None)
972 industrial = IndustrialTest(old_client, new_client,998 industrial = IndustrialTest(old_client, new_client,
973 [suite])999 [suite])
9741000
@@ -1145,7 +1171,7 @@
1145 def __init__(self):1171 def __init__(self):
1146 super(StubSA, self).__init__()1172 super(StubSA, self).__init__()
11471173
1148 self.assertIs(type(StubSA.factory(['a', 'b', 'c'])), StubSA)1174 self.assertIs(type(StubSA.factory(['a', 'b', 'c'], None)), StubSA)
11491175
1150 def test_get_test_info(self):1176 def test_get_test_info(self):
11511177
@@ -1670,21 +1696,22 @@
1670class TestPrepareUpgradeJujuAttempt(JujuPyTestCase):1696class TestPrepareUpgradeJujuAttempt(JujuPyTestCase):
16711697
1672 def test_factory(self):1698 def test_factory(self):
1673 uj_attempt = PrepareUpgradeJujuAttempt.factory(['a', 'b', 'c'])1699 uj_attempt = PrepareUpgradeJujuAttempt.factory(
1700 ['a', 'b', 'c'], None)
1674 self.assertIs(type(uj_attempt), PrepareUpgradeJujuAttempt)1701 self.assertIs(type(uj_attempt), PrepareUpgradeJujuAttempt)
1675 self.assertEqual(uj_attempt.bootstrap_paths, {'b': 'a', 'c': 'b'})1702 self.assertEqual(uj_attempt.bootstrap_paths, {'b': 'a', 'c': 'b'})
16761703
1677 def test_factory_empty(self):1704 def test_factory_empty(self):
1678 with self.assertRaisesRegexp(1705 with self.assertRaisesRegexp(
1679 ValueError, 'Not enough paths for upgrade.'):1706 ValueError, 'Not enough paths for upgrade.'):
1680 PrepareUpgradeJujuAttempt.factory(['a'])1707 PrepareUpgradeJujuAttempt.factory(['a'], None)
1681 with self.assertRaisesRegexp(1708 with self.assertRaisesRegexp(
1682 ValueError, 'Not enough paths for upgrade.'):1709 ValueError, 'Not enough paths for upgrade.'):
1683 PrepareUpgradeJujuAttempt.factory([])1710 PrepareUpgradeJujuAttempt.factory([], None)
16841711
1685 def test_get_bootstrap_client(self):1712 def test_get_bootstrap_client(self):
1686 client = FakeJujuClient(full_path='c', debug=True)1713 client = FakeJujuClient(full_path='c', debug=True)
1687 puj_attempt = PrepareUpgradeJujuAttempt.factory(['a', 'b', 'c'])1714 puj_attempt = PrepareUpgradeJujuAttempt.factory(['a', 'b', 'c'], None)
1688 bootstrap_client = puj_attempt.get_bootstrap_client(client)1715 bootstrap_client = puj_attempt.get_bootstrap_client(client)
1689 self.assertIsNot(bootstrap_client, client)1716 self.assertIsNot(bootstrap_client, client)
1690 self.assertIs(client.debug, bootstrap_client.debug)1717 self.assertIs(client.debug, bootstrap_client.debug)
@@ -1918,10 +1945,11 @@
1918 fake_bootstrap = FakeAttemptClass('bootstrap')1945 fake_bootstrap = FakeAttemptClass('bootstrap')
1919 factory = AttemptSuiteFactory([],1946 factory = AttemptSuiteFactory([],
1920 bootstrap_attempt=fake_bootstrap)1947 bootstrap_attempt=fake_bootstrap)
1921 attempt_suite = factory.factory(['1', '2'], 'log-1')1948 attempt_suite = factory.factory(['1', '2'], 'log-1', 'foo-stream')
1922 self.assertEqual(factory, attempt_suite.attempt_list)1949 self.assertEqual(factory, attempt_suite.attempt_list)
1923 self.assertEqual(['1', '2'], attempt_suite.upgrade_sequence)1950 self.assertEqual(['1', '2'], attempt_suite.upgrade_sequence)
1924 self.assertEqual('log-1', attempt_suite.log_dir)1951 self.assertEqual('log-1', attempt_suite.log_dir)
1952 self.assertEqual('foo-stream', attempt_suite.agent_stream)
19251953
1926 def test_get_test_info(self):1954 def test_get_test_info(self):
1927 fake_bootstrap = FakeAttemptClass('fake-bootstrap')1955 fake_bootstrap = FakeAttemptClass('fake-bootstrap')
@@ -1950,7 +1978,7 @@
1950 fake_2 = FakeAttemptClass('fake-2')1978 fake_2 = FakeAttemptClass('fake-2')
1951 factory = AttemptSuiteFactory([fake_1, fake_2],1979 factory = AttemptSuiteFactory([fake_1, fake_2],
1952 bootstrap_attempt=fake_bootstrap)1980 bootstrap_attempt=fake_bootstrap)
1953 attempt_suite = AttemptSuite(factory, None, None)1981 attempt_suite = AttemptSuite(factory, None, None, None)
1954 self.assertEqual(OrderedDict([1982 self.assertEqual(OrderedDict([
1955 ('fake-bootstrap-id', {'title': 'fake-bootstrap'}),1983 ('fake-bootstrap-id', {'title': 'fake-bootstrap'}),
1956 ('prepare-suite', {'title': 'Prepare suite tests',1984 ('prepare-suite', {'title': 'Prepare suite tests',
@@ -1963,24 +1991,41 @@
1963 'report_on': True}),1991 'report_on': True}),
1964 ]), attempt_suite.get_test_info())1992 ]), attempt_suite.get_test_info())
19651993
1994 @contextmanager
1995 def iter_steps_cxt(self, attempt_suite):
1996 with patch('industrial_test.BootstrapManager') as mock_bm:
1997 with patch.object(attempt_suite,
1998 '_iter_bs_manager_steps') as mock_ibms:
1999 with patch('industrial_test.make_log_dir',
2000 return_value='qux-1'):
2001 yield (mock_ibms, mock_bm)
2002
1966 def test_iter_steps(self):2003 def test_iter_steps(self):
1967 fake_bootstrap = FakeAttemptClass('fake-bootstrap', '1', '2')2004 fake_bootstrap = FakeAttemptClass('fake-bootstrap', '1', '2')
1968 with temp_dir() as log_dir:2005 factory = AttemptSuiteFactory([], bootstrap_attempt=fake_bootstrap)
1969 factory = AttemptSuiteFactory([], bootstrap_attempt=fake_bootstrap)2006 attempt_suite = AttemptSuite(factory, None, 'asdf', None)
1970 attempt_suite = AttemptSuite(factory, None, log_dir)2007 with self.iter_steps_cxt(attempt_suite) as (mock_ibms, mock_bm):
1971 client = FakeJujuClient()2008 client = FakeJujuClient()
1972 with patch('industrial_test.BootstrapManager') as mock_bm:2009 attempt_suite.iter_steps(client)
1973 with patch.object(attempt_suite,2010 mock_bm.assert_called_once_with(
1974 '_iter_bs_manager_steps') as mock_ibms:2011 'name', client, client, agent_stream=None, agent_url=None,
1975 iterator = attempt_suite.iter_steps(client)2012 bootstrap_host=None, jes_enabled=False, keep_env=True,
2013 log_dir='qux-1', machines=[], permanent=False,
2014 region=None, series=None)
2015
2016 def test_iter_steps_agent_stream(self):
2017 fake_bootstrap = FakeAttemptClass('fake-bootstrap', '1', '2')
2018 factory = AttemptSuiteFactory([], bootstrap_attempt=fake_bootstrap)
2019 attempt_suite = AttemptSuite(factory, None, 'asdf', 'bar-stream')
2020 with self.iter_steps_cxt(attempt_suite) as (mock_ibms, mock_bm):
2021 client = FakeJujuClient()
2022 iterator = attempt_suite.iter_steps(client)
1976 self.assertEqual(iterator, mock_ibms.return_value)2023 self.assertEqual(iterator, mock_ibms.return_value)
1977 mock_bm.assert_called_once_with(2024 mock_bm.assert_called_once_with(
1978 'name', client, client, agent_stream=None, agent_url=None,2025 'name', client, client, agent_stream='bar-stream', agent_url=None,
1979 bootstrap_host=None, jes_enabled=False, keep_env=True,2026 bootstrap_host=None, jes_enabled=False, keep_env=True,
1980 log_dir=os.path.join(log_dir, '0'), machines=[], permanent=False,2027 log_dir='qux-1', machines=[], permanent=False,
1981 region=None, series=None)2028 region=None, series=None)
1982 mock_ibms.assert_called_once_with(mock_bm.return_value, client,
1983 fake_bootstrap(), False)
19842029
1985 def test__iter_bs_manager_steps(self):2030 def test__iter_bs_manager_steps(self):
1986 fake_bootstrap = FakeAttemptClass('fake-bootstrap', '1', '2')2031 fake_bootstrap = FakeAttemptClass('fake-bootstrap', '1', '2')
@@ -1988,7 +2033,7 @@
1988 fake_2 = FakeAttemptClass('fake-2', '1', '2')2033 fake_2 = FakeAttemptClass('fake-2', '1', '2')
1989 factory = AttemptSuiteFactory([fake_1, fake_2],2034 factory = AttemptSuiteFactory([fake_1, fake_2],
1990 bootstrap_attempt=fake_bootstrap)2035 bootstrap_attempt=fake_bootstrap)
1991 attempt_suite = AttemptSuite(factory, None, None)2036 attempt_suite = AttemptSuite(factory, None, None, None)
1992 client = FakeJujuClient()2037 client = FakeJujuClient()
1993 bs_manager = FakeBootstrapManager(client)2038 bs_manager = FakeBootstrapManager(client)
1994 steps = list(attempt_suite._iter_bs_manager_steps(2039 steps = list(attempt_suite._iter_bs_manager_steps(

Subscribers

People subscribed via source and target branches