Merge lp:~abentley/juju-ci-tools/industrial-agent-stream into lp:juju-ci-tools
- industrial-agent-stream
- Merge into trunk
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 |
Related bugs: |
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.
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
1 | === modified file 'industrial_test.py' | |||
2 | --- industrial_test.py 2016-01-13 21:31:55 +0000 | |||
3 | +++ industrial_test.py 2016-01-14 21:01:47 +0000 | |||
4 | @@ -72,6 +72,7 @@ | |||
5 | 72 | :ivar new_juju_path: Path to the non-system juju. | 72 | :ivar new_juju_path: Path to the non-system juju. |
6 | 73 | :ivar stages: A list of StageAttempts. | 73 | :ivar stages: A list of StageAttempts. |
7 | 74 | :ivar attempt_count: The number of attempts needed for each stage. | 74 | :ivar attempt_count: The number of attempts needed for each stage. |
8 | 75 | :ivar agent_stream: The agent stream to use for testing. | ||
9 | 75 | """ | 76 | """ |
10 | 76 | 77 | ||
11 | 77 | @classmethod | 78 | @classmethod |
12 | @@ -80,7 +81,8 @@ | |||
13 | 80 | stages = cls.get_stages(suite, config) | 81 | stages = cls.get_stages(suite, config) |
14 | 81 | return cls(args.env, args.new_juju_path, | 82 | return cls(args.env, args.new_juju_path, |
15 | 82 | stages, args.log_dir, args.attempts, args.attempts * 2, | 83 | stages, args.log_dir, args.attempts, args.attempts * 2, |
17 | 83 | args.new_agent_url, args.debug, args.old_stable) | 84 | args.new_agent_url, args.debug, args.old_stable, |
18 | 85 | args.agent_stream) | ||
19 | 84 | 86 | ||
20 | 85 | @staticmethod | 87 | @staticmethod |
21 | 86 | def get_stages(suite, config): | 88 | def get_stages(suite, config): |
22 | @@ -88,7 +90,7 @@ | |||
23 | 88 | 90 | ||
24 | 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, |
25 | 90 | max_attempts=1, new_agent_url=None, debug=False, | 92 | max_attempts=1, new_agent_url=None, debug=False, |
27 | 91 | really_old_path=None): | 93 | really_old_path=None, agent_stream=None): |
28 | 92 | self.env = env | 94 | self.env = env |
29 | 93 | self.really_old_path = really_old_path | 95 | self.really_old_path = really_old_path |
30 | 94 | self.new_juju_path = new_juju_path | 96 | self.new_juju_path = new_juju_path |
31 | @@ -98,6 +100,7 @@ | |||
32 | 98 | self.max_attempts = max_attempts | 100 | self.max_attempts = max_attempts |
33 | 99 | self.debug = debug | 101 | self.debug = debug |
34 | 100 | self.log_parent_dir = log_dir | 102 | self.log_parent_dir = log_dir |
35 | 103 | self.agent_stream = agent_stream | ||
36 | 101 | 104 | ||
37 | 102 | def make_results(self): | 105 | def make_results(self): |
38 | 103 | """Return a results list for use in run_tests.""" | 106 | """Return a results list for use in run_tests.""" |
39 | @@ -150,7 +153,8 @@ | |||
40 | 150 | paths = [self.really_old_path, stable_path, self.new_juju_path] | 153 | paths = [self.really_old_path, stable_path, self.new_juju_path] |
41 | 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] |
42 | 152 | stage_attempts = [self.stages.factory(upgrade_sequence, | 155 | stage_attempts = [self.stages.factory(upgrade_sequence, |
44 | 153 | self.log_parent_dir)] | 156 | self.log_parent_dir, |
45 | 157 | self.agent_stream)] | ||
46 | 154 | return IndustrialTest.from_args(self.env, self.new_juju_path, | 158 | return IndustrialTest.from_args(self.env, self.new_juju_path, |
47 | 155 | stage_attempts, self.new_agent_url, | 159 | stage_attempts, self.new_agent_url, |
48 | 156 | self.debug) | 160 | self.debug) |
49 | @@ -273,7 +277,7 @@ | |||
50 | 273 | """ | 277 | """ |
51 | 274 | 278 | ||
52 | 275 | @classmethod | 279 | @classmethod |
54 | 276 | def factory(cls, upgrade_sequence): | 280 | def factory(cls, upgrade_sequence, agent_stream): |
55 | 277 | return cls() | 281 | return cls() |
56 | 278 | 282 | ||
57 | 279 | @staticmethod | 283 | @staticmethod |
58 | @@ -428,7 +432,7 @@ | |||
59 | 428 | return dict([cls.prepare_upgrade.as_tuple()]) | 432 | return dict([cls.prepare_upgrade.as_tuple()]) |
60 | 429 | 433 | ||
61 | 430 | @classmethod | 434 | @classmethod |
63 | 431 | def factory(cls, upgrade_sequence): | 435 | def factory(cls, upgrade_sequence, agent_stream): |
64 | 432 | if len(upgrade_sequence) < 2: | 436 | if len(upgrade_sequence) < 2: |
65 | 433 | raise ValueError('Not enough paths for upgrade.') | 437 | raise ValueError('Not enough paths for upgrade.') |
66 | 434 | bootstrap_paths = dict( | 438 | bootstrap_paths = dict( |
67 | @@ -821,14 +825,15 @@ | |||
68 | 821 | result.update(DestroyEnvironmentAttempt.get_test_info()) | 825 | result.update(DestroyEnvironmentAttempt.get_test_info()) |
69 | 822 | return result | 826 | return result |
70 | 823 | 827 | ||
72 | 824 | def factory(self, upgrade_sequence, log_dir): | 828 | def factory(self, upgrade_sequence, log_dir, agent_stream): |
73 | 825 | """Emit an AttemptSuite. | 829 | """Emit an AttemptSuite. |
74 | 826 | 830 | ||
75 | 827 | :param upgrade_sequence: The sequence of jujus to upgrade, for | 831 | :param upgrade_sequence: The sequence of jujus to upgrade, for |
76 | 828 | UpgradeJujuAttempt. | 832 | UpgradeJujuAttempt. |
77 | 829 | :param log_dir: Directory to store logs and other artifacts in. | 833 | :param log_dir: Directory to store logs and other artifacts in. |
78 | 834 | :param agent_stream: The agent stream to use for testing. | ||
79 | 830 | """ | 835 | """ |
81 | 831 | return AttemptSuite(self, upgrade_sequence, log_dir) | 836 | return AttemptSuite(self, upgrade_sequence, log_dir, agent_stream) |
82 | 832 | 837 | ||
83 | 833 | 838 | ||
84 | 834 | class AttemptSuite(SteppedStageAttempt): | 839 | class AttemptSuite(SteppedStageAttempt): |
85 | @@ -839,12 +844,14 @@ | |||
86 | 839 | :ivar upgrade_sequence: The sequence of jujus to upgrade, for | 844 | :ivar upgrade_sequence: The sequence of jujus to upgrade, for |
87 | 840 | UpgradeJujuAttempt. | 845 | UpgradeJujuAttempt. |
88 | 841 | :ivar log_dir: Directory to store logs and other artifacts in. | 846 | :ivar log_dir: Directory to store logs and other artifacts in. |
89 | 847 | :ivar agent_stream: The agent stream to use for testing. | ||
90 | 842 | """ | 848 | """ |
91 | 843 | 849 | ||
93 | 844 | def __init__(self, attempt_list, upgrade_sequence, log_dir): | 850 | def __init__(self, attempt_list, upgrade_sequence, log_dir, agent_stream): |
94 | 845 | self.attempt_list = attempt_list | 851 | self.attempt_list = attempt_list |
95 | 846 | self.upgrade_sequence = upgrade_sequence | 852 | self.upgrade_sequence = upgrade_sequence |
96 | 847 | self.log_dir = log_dir | 853 | self.log_dir = log_dir |
97 | 854 | self.agent_stream = agent_stream | ||
98 | 848 | 855 | ||
99 | 849 | def get_test_info(self): | 856 | def get_test_info(self): |
100 | 850 | """Describe the tests provided by this Stage.""" | 857 | """Describe the tests provided by this Stage.""" |
101 | @@ -862,15 +869,16 @@ | |||
102 | 862 | The actual generator is _iter_bs_manager_steps, to simplify testing. | 869 | The actual generator is _iter_bs_manager_steps, to simplify testing. |
103 | 863 | """ | 870 | """ |
104 | 864 | bootstrap_attempt = self.attempt_list.bootstrap_attempt.factory( | 871 | bootstrap_attempt = self.attempt_list.bootstrap_attempt.factory( |
106 | 865 | self.upgrade_sequence) | 872 | self.upgrade_sequence, self.agent_stream) |
107 | 866 | bs_client = bootstrap_attempt.get_bootstrap_client(client) | 873 | bs_client = bootstrap_attempt.get_bootstrap_client(client) |
108 | 867 | bs_jes_enabled = bs_client.is_jes_enabled() | 874 | bs_jes_enabled = bs_client.is_jes_enabled() |
109 | 868 | jes_enabled = client.is_jes_enabled() | 875 | jes_enabled = client.is_jes_enabled() |
110 | 869 | bs_manager = BootstrapManager( | 876 | bs_manager = BootstrapManager( |
111 | 870 | client.env.environment, bs_client, bs_client, | 877 | client.env.environment, bs_client, bs_client, |
112 | 871 | bootstrap_host=None, | 878 | bootstrap_host=None, |
115 | 872 | machines=[], series=None, agent_url=None, agent_stream=None, | 879 | machines=[], series=None, agent_url=None, |
116 | 873 | region=None, log_dir=make_log_dir(self.log_dir), keep_env=True, | 880 | agent_stream=self.agent_stream, region=None, |
117 | 881 | log_dir=make_log_dir(self.log_dir), keep_env=True, | ||
118 | 874 | permanent=jes_enabled, jes_enabled=bs_jes_enabled) | 882 | permanent=jes_enabled, jes_enabled=bs_jes_enabled) |
119 | 875 | return self._iter_bs_manager_steps(bs_manager, client, | 883 | return self._iter_bs_manager_steps(bs_manager, client, |
120 | 876 | bootstrap_attempt, jes_enabled) | 884 | bootstrap_attempt, jes_enabled) |
121 | @@ -890,8 +898,9 @@ | |||
122 | 890 | bs_manager.client = client | 898 | bs_manager.client = client |
123 | 891 | bs_manager.tear_down_client = client | 899 | bs_manager.tear_down_client = client |
124 | 892 | bs_manager.jes_enabled = jes_enabled | 900 | bs_manager.jes_enabled = jes_enabled |
127 | 893 | attempts = [a.factory(self.upgrade_sequence) for a in | 901 | attempts = [ |
128 | 894 | self.attempt_list.attempt_list] | 902 | a.factory(self.upgrade_sequence, self.agent_stream) |
129 | 903 | for a in self.attempt_list.attempt_list] | ||
130 | 895 | yield self.attempt_list.prepare_suite.as_result(True) | 904 | yield self.attempt_list.prepare_suite.as_result(True) |
131 | 896 | for attempt in attempts: | 905 | for attempt in attempts: |
132 | 897 | for result in attempt.iter_steps(client): | 906 | for result in attempt.iter_steps(client): |
133 | @@ -958,6 +967,8 @@ | |||
134 | 958 | parser.add_argument('--new-agent-url') | 967 | parser.add_argument('--new-agent-url') |
135 | 959 | parser.add_argument('--single', action='store_true') | 968 | parser.add_argument('--single', action='store_true') |
136 | 960 | parser.add_argument('--debug', action='store_true', default=False) | 969 | parser.add_argument('--debug', action='store_true', default=False) |
137 | 970 | parser.add_argument('--agent-stream', | ||
138 | 971 | help='Agent stream to use for tests.') | ||
139 | 961 | parser.add_argument( | 972 | parser.add_argument( |
140 | 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' |
141 | 963 | ' upgrade from.') | 974 | ' upgrade from.') |
142 | @@ -981,7 +992,8 @@ | |||
143 | 981 | for suite in args.suite: | 992 | for suite in args.suite: |
144 | 982 | factory = MultiIndustrialTest.get_stages(suite, env.config) | 993 | factory = MultiIndustrialTest.get_stages(suite, env.config) |
145 | 983 | upgrade_sequence = [upgrade_client.full_path, client.full_path] | 994 | upgrade_sequence = [upgrade_client.full_path, client.full_path] |
147 | 984 | suite = factory.factory(upgrade_sequence, args.log_dir) | 995 | suite = factory.factory(upgrade_sequence, args.log_dir, |
148 | 996 | args.agent_stream) | ||
149 | 985 | steps_iter = suite.iter_steps(client) | 997 | steps_iter = suite.iter_steps(client) |
150 | 986 | for step in steps_iter: | 998 | for step in steps_iter: |
151 | 987 | print(step) | 999 | print(step) |
152 | 988 | 1000 | ||
153 | === modified file 'run-reliability-test.bash' | |||
154 | --- run-reliability-test.bash 2015-03-02 21:22:28 +0000 | |||
155 | +++ run-reliability-test.bash 2016-01-14 21:01:47 +0000 | |||
156 | @@ -15,11 +15,13 @@ | |||
157 | 15 | fi | 15 | fi |
158 | 16 | set -x | 16 | set -x |
159 | 17 | # Delete all files in $WORKSPACE, but no error if empty. | 17 | # Delete all files in $WORKSPACE, but no error if empty. |
161 | 18 | find $WORKSPACE -type f -delete | 18 | find $WORKSPACE -mindepth 1 -delete |
162 | 19 | logs=$WORKSPACE/logs | ||
163 | 20 | mkdir $logs | ||
164 | 19 | $SCRIPTS/write_industrial_test_metadata.py $new_juju_dir/buildvars.json \ | 21 | $SCRIPTS/write_industrial_test_metadata.py $new_juju_dir/buildvars.json \ |
165 | 20 | $environment metadata.json | 22 | $environment metadata.json |
166 | 21 | s3cmd -c $s3cfg put metadata.json $s3base-metadata.json | 23 | s3cmd -c $s3cfg put metadata.json $s3base-metadata.json |
167 | 22 | timeout -sINT -k 10m 1d $SCRIPTS/industrial_test.py $environment $new_juju \ | 24 | timeout -sINT -k 10m 1d $SCRIPTS/industrial_test.py $environment $new_juju \ |
169 | 23 | --old-stable $old_stable_juju $suite --attempts $attempts \ | 25 | $logs --old-stable $old_stable_juju $suite --attempts $attempts \ |
170 | 24 | --json-file results.json $extra_args | 26 | --json-file results.json $extra_args |
171 | 25 | s3cmd -c $s3cfg put results.json $s3base-results.json | 27 | s3cmd -c $s3cfg put results.json $s3base-results.json |
172 | 26 | 28 | ||
173 | === modified file 'tests/test_industrial_test.py' | |||
174 | --- tests/test_industrial_test.py 2016-01-13 21:33:11 +0000 | |||
175 | +++ tests/test_industrial_test.py 2016-01-14 21:01:47 +0000 | |||
176 | @@ -164,6 +164,7 @@ | |||
177 | 164 | self.assertEqual(args.new_juju_path, 'new-juju') | 164 | self.assertEqual(args.new_juju_path, 'new-juju') |
178 | 165 | self.assertEqual(args.log_dir, 'log-dir') | 165 | self.assertEqual(args.log_dir, 'log-dir') |
179 | 166 | self.assertEqual(args.suite, [QUICK]) | 166 | self.assertEqual(args.suite, [QUICK]) |
180 | 167 | self.assertIs(args.agent_stream, None) | ||
181 | 167 | 168 | ||
182 | 168 | def test_parse_args_attempts(self): | 169 | def test_parse_args_attempts(self): |
183 | 169 | args = parse_args(['rai', 'new-juju', QUICK, 'log-dir']) | 170 | args = parse_args(['rai', 'new-juju', QUICK, 'log-dir']) |
184 | @@ -221,6 +222,13 @@ | |||
185 | 221 | args = parse_args(['rai', 'new-juju', QUICK, 'log-dir']) | 222 | args = parse_args(['rai', 'new-juju', QUICK, 'log-dir']) |
186 | 222 | self.assertIs(args.old_stable, None) | 223 | self.assertIs(args.old_stable, None) |
187 | 223 | 224 | ||
188 | 225 | def test_parse_args_agent_stream(self): | ||
189 | 226 | args = parse_args(['rai', 'new-juju', QUICK, 'log-dir', | ||
190 | 227 | '--agent-stream', 'asdf']) | ||
191 | 228 | self.assertEqual(args.agent_stream, 'asdf') | ||
192 | 229 | args = parse_args(['rai', 'new-juju', QUICK, 'log-dir']) | ||
193 | 230 | self.assertIs(args.old_stable, None) | ||
194 | 231 | |||
195 | 224 | 232 | ||
196 | 225 | class FakeStepAttempt: | 233 | class FakeStepAttempt: |
197 | 226 | 234 | ||
198 | @@ -265,7 +273,7 @@ | |||
199 | 265 | normal methods on FakeAttemptClass. | 273 | normal methods on FakeAttemptClass. |
200 | 266 | """ | 274 | """ |
201 | 267 | 275 | ||
203 | 268 | def factory(self, upgrade_sequence): | 276 | def factory(self, upgrade_sequence, attempt_stream): |
204 | 269 | return self() | 277 | return self() |
205 | 270 | 278 | ||
206 | 271 | def __init__(self, title, *result, **kwargs): | 279 | def __init__(self, title, *result, **kwargs): |
207 | @@ -301,7 +309,7 @@ | |||
208 | 301 | args = Namespace( | 309 | args = Namespace( |
209 | 302 | env='foo', new_juju_path='new-path', attempts=7, suite=[DENSITY], | 310 | env='foo', new_juju_path='new-path', attempts=7, suite=[DENSITY], |
210 | 303 | log_dir='log-dir', new_agent_url=None, debug=False, | 311 | log_dir='log-dir', new_agent_url=None, debug=False, |
212 | 304 | old_stable=None) | 312 | old_stable=None, agent_stream=None) |
213 | 305 | with temp_env('foo'): | 313 | with temp_env('foo'): |
214 | 306 | mit = MultiIndustrialTest.from_args(args, QUICK) | 314 | mit = MultiIndustrialTest.from_args(args, QUICK) |
215 | 307 | self.assertEqual(mit.env, 'foo') | 315 | self.assertEqual(mit.env, 'foo') |
216 | @@ -309,12 +317,13 @@ | |||
217 | 309 | self.assertEqual(mit.attempt_count, 7) | 317 | self.assertEqual(mit.attempt_count, 7) |
218 | 310 | self.assertEqual(mit.max_attempts, 14) | 318 | self.assertEqual(mit.max_attempts, 14) |
219 | 311 | self.assertEqual(mit.log_parent_dir, 'log-dir') | 319 | self.assertEqual(mit.log_parent_dir, 'log-dir') |
220 | 320 | self.assertIs(mit.agent_stream, None) | ||
221 | 312 | self.assertEqual( | 321 | self.assertEqual( |
222 | 313 | mit.stages, AttemptSuiteFactory([])) | 322 | mit.stages, AttemptSuiteFactory([])) |
223 | 314 | args = Namespace( | 323 | args = Namespace( |
224 | 315 | env='bar', new_juju_path='new-path2', attempts=6, suite=[FULL], | 324 | env='bar', new_juju_path='new-path2', attempts=6, suite=[FULL], |
225 | 316 | log_dir='log-dir2', new_agent_url=None, debug=False, | 325 | log_dir='log-dir2', new_agent_url=None, debug=False, |
227 | 317 | old_stable=None) | 326 | old_stable=None, agent_stream=None) |
228 | 318 | with temp_env('bar'): | 327 | with temp_env('bar'): |
229 | 319 | mit = MultiIndustrialTest.from_args(args, FULL) | 328 | mit = MultiIndustrialTest.from_args(args, FULL) |
230 | 320 | self.assertEqual(mit.env, 'bar') | 329 | self.assertEqual(mit.env, 'bar') |
231 | @@ -322,6 +331,7 @@ | |||
232 | 322 | self.assertEqual(mit.attempt_count, 6) | 331 | self.assertEqual(mit.attempt_count, 6) |
233 | 323 | self.assertEqual(mit.max_attempts, 12) | 332 | self.assertEqual(mit.max_attempts, 12) |
234 | 324 | self.assertEqual(mit.log_parent_dir, 'log-dir2') | 333 | self.assertEqual(mit.log_parent_dir, 'log-dir2') |
235 | 334 | self.assertIs(mit.agent_stream, None) | ||
236 | 325 | self.assertEqual( | 335 | self.assertEqual( |
237 | 326 | mit.stages, AttemptSuiteFactory([ | 336 | mit.stages, AttemptSuiteFactory([ |
238 | 327 | UpgradeCharmAttempt, DeployManyAttempt, | 337 | UpgradeCharmAttempt, DeployManyAttempt, |
239 | @@ -330,7 +340,8 @@ | |||
240 | 330 | def test_from_args_maas(self): | 340 | def test_from_args_maas(self): |
241 | 331 | args = Namespace( | 341 | args = Namespace( |
242 | 332 | env='foo', new_juju_path='new-path', log_dir='log-dir', | 342 | env='foo', new_juju_path='new-path', log_dir='log-dir', |
244 | 333 | attempts=7, new_agent_url=None, debug=False, old_stable=None) | 343 | attempts=7, new_agent_url=None, debug=False, old_stable=None, |
245 | 344 | agent_stream=None) | ||
246 | 334 | with temp_env('foo', {'type': 'maas'}): | 345 | with temp_env('foo', {'type': 'maas'}): |
247 | 335 | mit = MultiIndustrialTest.from_args(args, DENSITY) | 346 | mit = MultiIndustrialTest.from_args(args, DENSITY) |
248 | 336 | self.assertEqual( | 347 | self.assertEqual( |
249 | @@ -339,7 +350,8 @@ | |||
250 | 339 | def test_from_args_debug(self): | 350 | def test_from_args_debug(self): |
251 | 340 | args = Namespace( | 351 | args = Namespace( |
252 | 341 | env='foo', new_juju_path='new-path', log_dir='log-dir', | 352 | env='foo', new_juju_path='new-path', log_dir='log-dir', |
254 | 342 | attempts=7, new_agent_url=None, debug=False, old_stable=None) | 353 | attempts=7, new_agent_url=None, debug=False, old_stable=None, |
255 | 354 | agent_stream=None) | ||
256 | 343 | with temp_env('foo', {'type': 'maas'}): | 355 | with temp_env('foo', {'type': 'maas'}): |
257 | 344 | mit = MultiIndustrialTest.from_args(args, DENSITY) | 356 | mit = MultiIndustrialTest.from_args(args, DENSITY) |
258 | 345 | self.assertEqual(mit.debug, False) | 357 | self.assertEqual(mit.debug, False) |
259 | @@ -351,17 +363,30 @@ | |||
260 | 351 | args = Namespace( | 363 | args = Namespace( |
261 | 352 | env='foo', new_juju_path='new-path', log_dir='log-dir', | 364 | env='foo', new_juju_path='new-path', log_dir='log-dir', |
262 | 353 | attempts=7, new_agent_url=None, debug=False, | 365 | attempts=7, new_agent_url=None, debug=False, |
264 | 354 | old_stable='really-old-path') | 366 | old_stable='really-old-path', agent_stream=None) |
265 | 355 | with temp_env('foo'): | 367 | with temp_env('foo'): |
266 | 356 | mit = MultiIndustrialTest.from_args(args, FULL) | 368 | mit = MultiIndustrialTest.from_args(args, FULL) |
267 | 357 | self.assertEqual(mit.really_old_path, 'really-old-path') | 369 | self.assertEqual(mit.really_old_path, 'really-old-path') |
268 | 358 | args = Namespace( | 370 | args = Namespace( |
269 | 359 | env='bar', new_juju_path='new-path2', log_dir='log-dir', | 371 | env='bar', new_juju_path='new-path2', log_dir='log-dir', |
271 | 360 | attempts=6, new_agent_url=None, debug=False, old_stable=None) | 372 | attempts=6, new_agent_url=None, debug=False, old_stable=None, |
272 | 373 | agent_stream=None) | ||
273 | 361 | with temp_env('bar'): | 374 | with temp_env('bar'): |
274 | 362 | mit = MultiIndustrialTest.from_args(args, FULL) | 375 | mit = MultiIndustrialTest.from_args(args, FULL) |
275 | 363 | self.assertIs(mit.really_old_path, None) | 376 | self.assertIs(mit.really_old_path, None) |
276 | 364 | 377 | ||
277 | 378 | def test_from_args_agent_stream(self): | ||
278 | 379 | args = Namespace( | ||
279 | 380 | env='foo', new_juju_path='new-path', log_dir='log-dir', | ||
280 | 381 | attempts=7, new_agent_url=None, debug=False, old_stable=None, | ||
281 | 382 | agent_stream='foo-stream') | ||
282 | 383 | with temp_env('foo', {'type': 'maas'}): | ||
283 | 384 | mit = MultiIndustrialTest.from_args(args, DENSITY) | ||
284 | 385 | self.assertEqual(mit.debug, False) | ||
285 | 386 | args.debug = True | ||
286 | 387 | mit = MultiIndustrialTest.from_args(args, DENSITY) | ||
287 | 388 | self.assertEqual(mit.agent_stream, 'foo-stream') | ||
288 | 389 | |||
289 | 365 | def test_get_stages(self): | 390 | def test_get_stages(self): |
290 | 366 | self.assertEqual( | 391 | self.assertEqual( |
291 | 367 | MultiIndustrialTest.get_stages(QUICK, {'type': 'foo'}), | 392 | MultiIndustrialTest.get_stages(QUICK, {'type': 'foo'}), |
292 | @@ -399,7 +424,7 @@ | |||
293 | 399 | args = Namespace( | 424 | args = Namespace( |
294 | 400 | env='foo', new_juju_path='new-path', attempts=7, | 425 | env='foo', new_juju_path='new-path', attempts=7, |
295 | 401 | log_dir='log-dir', new_agent_url=None, debug=False, | 426 | log_dir='log-dir', new_agent_url=None, debug=False, |
297 | 402 | old_stable=None) | 427 | old_stable=None, agent_stream=None) |
298 | 403 | with temp_env('foo'): | 428 | with temp_env('foo'): |
299 | 404 | mit = MultiIndustrialTest.from_args(args, DENSITY) | 429 | mit = MultiIndustrialTest.from_args(args, DENSITY) |
300 | 405 | self.assertEqual( | 430 | self.assertEqual( |
301 | @@ -409,7 +434,7 @@ | |||
302 | 409 | args = Namespace( | 434 | args = Namespace( |
303 | 410 | env='foo', new_juju_path='new-path', attempts=7, | 435 | env='foo', new_juju_path='new-path', attempts=7, |
304 | 411 | log_dir='log-dir', new_agent_url=None, debug=False, | 436 | log_dir='log-dir', new_agent_url=None, debug=False, |
306 | 412 | old_stable=None) | 437 | old_stable=None, agent_stream=None) |
307 | 413 | with temp_env('foo'): | 438 | with temp_env('foo'): |
308 | 414 | mit = MultiIndustrialTest.from_args(args, BACKUP) | 439 | mit = MultiIndustrialTest.from_args(args, BACKUP) |
309 | 415 | self.assertEqual( | 440 | self.assertEqual( |
310 | @@ -419,7 +444,7 @@ | |||
311 | 419 | args = Namespace( | 444 | args = Namespace( |
312 | 420 | env='foo', new_juju_path='new-path', attempts=7, | 445 | env='foo', new_juju_path='new-path', attempts=7, |
313 | 421 | log_dir='log-dir', new_agent_url='http://example.net', | 446 | log_dir='log-dir', new_agent_url='http://example.net', |
315 | 422 | debug=False, old_stable=None) | 447 | debug=False, old_stable=None, agent_stream=None) |
316 | 423 | with temp_env('foo'): | 448 | with temp_env('foo'): |
317 | 424 | mit = MultiIndustrialTest.from_args(args, suite=QUICK) | 449 | mit = MultiIndustrialTest.from_args(args, suite=QUICK) |
318 | 425 | self.assertEqual(mit.new_agent_url, 'http://example.net') | 450 | self.assertEqual(mit.new_agent_url, 'http://example.net') |
319 | @@ -872,7 +897,7 @@ | |||
320 | 872 | FakeAttemptClass('foo', False, True, new_path='bar-path'), | 897 | FakeAttemptClass('foo', False, True, new_path='bar-path'), |
321 | 873 | FakeAttemptClass('bar', True, True, new_path='bar-path')]) | 898 | FakeAttemptClass('bar', True, True, new_path='bar-path')]) |
322 | 874 | log_dir = use_context(self, temp_dir()) | 899 | log_dir = use_context(self, temp_dir()) |
324 | 875 | suite = suite_factory.factory([], log_dir) | 900 | suite = suite_factory.factory([], log_dir, None) |
325 | 876 | industrial = IndustrialTest(old_client, new_client, [suite]) | 901 | industrial = IndustrialTest(old_client, new_client, [suite]) |
326 | 877 | with patch('industrial_test.BootstrapManager', | 902 | with patch('industrial_test.BootstrapManager', |
327 | 878 | fake_bootstrap_manager): | 903 | fake_bootstrap_manager): |
328 | @@ -891,7 +916,7 @@ | |||
329 | 891 | suite_factory = AttemptSuiteFactory([ | 916 | suite_factory = AttemptSuiteFactory([ |
330 | 892 | FakeAttemptClass('foo', True, False, new_path='bar-path'), | 917 | FakeAttemptClass('foo', True, False, new_path='bar-path'), |
331 | 893 | FakeAttemptClass('bar', True, True, new_path='bar-path')]) | 918 | FakeAttemptClass('bar', True, True, new_path='bar-path')]) |
333 | 894 | suite = suite_factory.factory([], log_dir) | 919 | suite = suite_factory.factory([], log_dir, None) |
334 | 895 | industrial = IndustrialTest(old_client, new_client, [suite]) | 920 | industrial = IndustrialTest(old_client, new_client, [suite]) |
335 | 896 | with patch('industrial_test.BootstrapManager', | 921 | with patch('industrial_test.BootstrapManager', |
336 | 897 | fake_bootstrap_manager): | 922 | fake_bootstrap_manager): |
337 | @@ -909,7 +934,8 @@ | |||
338 | 909 | log_dir = use_context(self, temp_dir()) | 934 | log_dir = use_context(self, temp_dir()) |
339 | 910 | suite = AttemptSuiteFactory([ | 935 | suite = AttemptSuiteFactory([ |
340 | 911 | FakeAttemptClass('foo', False, False), | 936 | FakeAttemptClass('foo', False, False), |
342 | 912 | FakeAttemptClass('bar', True, True)]).factory([], log_dir) | 937 | FakeAttemptClass('bar', True, True)]).factory([], log_dir, |
343 | 938 | 'foo-stream') | ||
344 | 913 | industrial = IndustrialTest(old_client, new_client, [suite]) | 939 | industrial = IndustrialTest(old_client, new_client, [suite]) |
345 | 914 | with patch('industrial_test.BootstrapManager', | 940 | with patch('industrial_test.BootstrapManager', |
346 | 915 | fake_bootstrap_manager): | 941 | fake_bootstrap_manager): |
347 | @@ -968,7 +994,7 @@ | |||
348 | 968 | new_client = FakeJujuClient() | 994 | new_client = FakeJujuClient() |
349 | 969 | attempt = FakeStepAttempt.from_result(True, True) | 995 | attempt = FakeStepAttempt.from_result(True, True) |
350 | 970 | log_dir = use_context(self, temp_dir()) | 996 | log_dir = use_context(self, temp_dir()) |
352 | 971 | suite = AttemptSuiteFactory([attempt]).factory([], log_dir) | 997 | suite = AttemptSuiteFactory([attempt]).factory([], log_dir, None) |
353 | 972 | industrial = IndustrialTest(old_client, new_client, | 998 | industrial = IndustrialTest(old_client, new_client, |
354 | 973 | [suite]) | 999 | [suite]) |
355 | 974 | 1000 | ||
356 | @@ -1145,7 +1171,7 @@ | |||
357 | 1145 | def __init__(self): | 1171 | def __init__(self): |
358 | 1146 | super(StubSA, self).__init__() | 1172 | super(StubSA, self).__init__() |
359 | 1147 | 1173 | ||
361 | 1148 | self.assertIs(type(StubSA.factory(['a', 'b', 'c'])), StubSA) | 1174 | self.assertIs(type(StubSA.factory(['a', 'b', 'c'], None)), StubSA) |
362 | 1149 | 1175 | ||
363 | 1150 | def test_get_test_info(self): | 1176 | def test_get_test_info(self): |
364 | 1151 | 1177 | ||
365 | @@ -1670,21 +1696,22 @@ | |||
366 | 1670 | class TestPrepareUpgradeJujuAttempt(JujuPyTestCase): | 1696 | class TestPrepareUpgradeJujuAttempt(JujuPyTestCase): |
367 | 1671 | 1697 | ||
368 | 1672 | def test_factory(self): | 1698 | def test_factory(self): |
370 | 1673 | uj_attempt = PrepareUpgradeJujuAttempt.factory(['a', 'b', 'c']) | 1699 | uj_attempt = PrepareUpgradeJujuAttempt.factory( |
371 | 1700 | ['a', 'b', 'c'], None) | ||
372 | 1674 | self.assertIs(type(uj_attempt), PrepareUpgradeJujuAttempt) | 1701 | self.assertIs(type(uj_attempt), PrepareUpgradeJujuAttempt) |
373 | 1675 | self.assertEqual(uj_attempt.bootstrap_paths, {'b': 'a', 'c': 'b'}) | 1702 | self.assertEqual(uj_attempt.bootstrap_paths, {'b': 'a', 'c': 'b'}) |
374 | 1676 | 1703 | ||
375 | 1677 | def test_factory_empty(self): | 1704 | def test_factory_empty(self): |
376 | 1678 | with self.assertRaisesRegexp( | 1705 | with self.assertRaisesRegexp( |
377 | 1679 | ValueError, 'Not enough paths for upgrade.'): | 1706 | ValueError, 'Not enough paths for upgrade.'): |
379 | 1680 | PrepareUpgradeJujuAttempt.factory(['a']) | 1707 | PrepareUpgradeJujuAttempt.factory(['a'], None) |
380 | 1681 | with self.assertRaisesRegexp( | 1708 | with self.assertRaisesRegexp( |
381 | 1682 | ValueError, 'Not enough paths for upgrade.'): | 1709 | ValueError, 'Not enough paths for upgrade.'): |
383 | 1683 | PrepareUpgradeJujuAttempt.factory([]) | 1710 | PrepareUpgradeJujuAttempt.factory([], None) |
384 | 1684 | 1711 | ||
385 | 1685 | def test_get_bootstrap_client(self): | 1712 | def test_get_bootstrap_client(self): |
386 | 1686 | client = FakeJujuClient(full_path='c', debug=True) | 1713 | client = FakeJujuClient(full_path='c', debug=True) |
388 | 1687 | puj_attempt = PrepareUpgradeJujuAttempt.factory(['a', 'b', 'c']) | 1714 | puj_attempt = PrepareUpgradeJujuAttempt.factory(['a', 'b', 'c'], None) |
389 | 1688 | bootstrap_client = puj_attempt.get_bootstrap_client(client) | 1715 | bootstrap_client = puj_attempt.get_bootstrap_client(client) |
390 | 1689 | self.assertIsNot(bootstrap_client, client) | 1716 | self.assertIsNot(bootstrap_client, client) |
391 | 1690 | self.assertIs(client.debug, bootstrap_client.debug) | 1717 | self.assertIs(client.debug, bootstrap_client.debug) |
392 | @@ -1918,10 +1945,11 @@ | |||
393 | 1918 | fake_bootstrap = FakeAttemptClass('bootstrap') | 1945 | fake_bootstrap = FakeAttemptClass('bootstrap') |
394 | 1919 | factory = AttemptSuiteFactory([], | 1946 | factory = AttemptSuiteFactory([], |
395 | 1920 | bootstrap_attempt=fake_bootstrap) | 1947 | bootstrap_attempt=fake_bootstrap) |
397 | 1921 | attempt_suite = factory.factory(['1', '2'], 'log-1') | 1948 | attempt_suite = factory.factory(['1', '2'], 'log-1', 'foo-stream') |
398 | 1922 | self.assertEqual(factory, attempt_suite.attempt_list) | 1949 | self.assertEqual(factory, attempt_suite.attempt_list) |
399 | 1923 | self.assertEqual(['1', '2'], attempt_suite.upgrade_sequence) | 1950 | self.assertEqual(['1', '2'], attempt_suite.upgrade_sequence) |
400 | 1924 | self.assertEqual('log-1', attempt_suite.log_dir) | 1951 | self.assertEqual('log-1', attempt_suite.log_dir) |
401 | 1952 | self.assertEqual('foo-stream', attempt_suite.agent_stream) | ||
402 | 1925 | 1953 | ||
403 | 1926 | def test_get_test_info(self): | 1954 | def test_get_test_info(self): |
404 | 1927 | fake_bootstrap = FakeAttemptClass('fake-bootstrap') | 1955 | fake_bootstrap = FakeAttemptClass('fake-bootstrap') |
405 | @@ -1950,7 +1978,7 @@ | |||
406 | 1950 | fake_2 = FakeAttemptClass('fake-2') | 1978 | fake_2 = FakeAttemptClass('fake-2') |
407 | 1951 | factory = AttemptSuiteFactory([fake_1, fake_2], | 1979 | factory = AttemptSuiteFactory([fake_1, fake_2], |
408 | 1952 | bootstrap_attempt=fake_bootstrap) | 1980 | bootstrap_attempt=fake_bootstrap) |
410 | 1953 | attempt_suite = AttemptSuite(factory, None, None) | 1981 | attempt_suite = AttemptSuite(factory, None, None, None) |
411 | 1954 | self.assertEqual(OrderedDict([ | 1982 | self.assertEqual(OrderedDict([ |
412 | 1955 | ('fake-bootstrap-id', {'title': 'fake-bootstrap'}), | 1983 | ('fake-bootstrap-id', {'title': 'fake-bootstrap'}), |
413 | 1956 | ('prepare-suite', {'title': 'Prepare suite tests', | 1984 | ('prepare-suite', {'title': 'Prepare suite tests', |
414 | @@ -1963,24 +1991,41 @@ | |||
415 | 1963 | 'report_on': True}), | 1991 | 'report_on': True}), |
416 | 1964 | ]), attempt_suite.get_test_info()) | 1992 | ]), attempt_suite.get_test_info()) |
417 | 1965 | 1993 | ||
418 | 1994 | @contextmanager | ||
419 | 1995 | def iter_steps_cxt(self, attempt_suite): | ||
420 | 1996 | with patch('industrial_test.BootstrapManager') as mock_bm: | ||
421 | 1997 | with patch.object(attempt_suite, | ||
422 | 1998 | '_iter_bs_manager_steps') as mock_ibms: | ||
423 | 1999 | with patch('industrial_test.make_log_dir', | ||
424 | 2000 | return_value='qux-1'): | ||
425 | 2001 | yield (mock_ibms, mock_bm) | ||
426 | 2002 | |||
427 | 1966 | def test_iter_steps(self): | 2003 | def test_iter_steps(self): |
428 | 1967 | fake_bootstrap = FakeAttemptClass('fake-bootstrap', '1', '2') | 2004 | fake_bootstrap = FakeAttemptClass('fake-bootstrap', '1', '2') |
437 | 1968 | with temp_dir() as log_dir: | 2005 | factory = AttemptSuiteFactory([], bootstrap_attempt=fake_bootstrap) |
438 | 1969 | factory = AttemptSuiteFactory([], bootstrap_attempt=fake_bootstrap) | 2006 | attempt_suite = AttemptSuite(factory, None, 'asdf', None) |
439 | 1970 | attempt_suite = AttemptSuite(factory, None, log_dir) | 2007 | with self.iter_steps_cxt(attempt_suite) as (mock_ibms, mock_bm): |
440 | 1971 | client = FakeJujuClient() | 2008 | client = FakeJujuClient() |
441 | 1972 | with patch('industrial_test.BootstrapManager') as mock_bm: | 2009 | attempt_suite.iter_steps(client) |
442 | 1973 | with patch.object(attempt_suite, | 2010 | mock_bm.assert_called_once_with( |
443 | 1974 | '_iter_bs_manager_steps') as mock_ibms: | 2011 | 'name', client, client, agent_stream=None, agent_url=None, |
444 | 1975 | iterator = attempt_suite.iter_steps(client) | 2012 | bootstrap_host=None, jes_enabled=False, keep_env=True, |
445 | 2013 | log_dir='qux-1', machines=[], permanent=False, | ||
446 | 2014 | region=None, series=None) | ||
447 | 2015 | |||
448 | 2016 | def test_iter_steps_agent_stream(self): | ||
449 | 2017 | fake_bootstrap = FakeAttemptClass('fake-bootstrap', '1', '2') | ||
450 | 2018 | factory = AttemptSuiteFactory([], bootstrap_attempt=fake_bootstrap) | ||
451 | 2019 | attempt_suite = AttemptSuite(factory, None, 'asdf', 'bar-stream') | ||
452 | 2020 | with self.iter_steps_cxt(attempt_suite) as (mock_ibms, mock_bm): | ||
453 | 2021 | client = FakeJujuClient() | ||
454 | 2022 | iterator = attempt_suite.iter_steps(client) | ||
455 | 1976 | self.assertEqual(iterator, mock_ibms.return_value) | 2023 | self.assertEqual(iterator, mock_ibms.return_value) |
456 | 1977 | mock_bm.assert_called_once_with( | 2024 | mock_bm.assert_called_once_with( |
458 | 1978 | 'name', client, client, agent_stream=None, agent_url=None, | 2025 | 'name', client, client, agent_stream='bar-stream', agent_url=None, |
459 | 1979 | bootstrap_host=None, jes_enabled=False, keep_env=True, | 2026 | bootstrap_host=None, jes_enabled=False, keep_env=True, |
461 | 1980 | log_dir=os.path.join(log_dir, '0'), machines=[], permanent=False, | 2027 | log_dir='qux-1', machines=[], permanent=False, |
462 | 1981 | region=None, series=None) | 2028 | region=None, series=None) |
463 | 1982 | mock_ibms.assert_called_once_with(mock_bm.return_value, client, | ||
464 | 1983 | fake_bootstrap(), False) | ||
465 | 1984 | 2029 | ||
466 | 1985 | def test__iter_bs_manager_steps(self): | 2030 | def test__iter_bs_manager_steps(self): |
467 | 1986 | fake_bootstrap = FakeAttemptClass('fake-bootstrap', '1', '2') | 2031 | fake_bootstrap = FakeAttemptClass('fake-bootstrap', '1', '2') |
468 | @@ -1988,7 +2033,7 @@ | |||
469 | 1988 | fake_2 = FakeAttemptClass('fake-2', '1', '2') | 2033 | fake_2 = FakeAttemptClass('fake-2', '1', '2') |
470 | 1989 | factory = AttemptSuiteFactory([fake_1, fake_2], | 2034 | factory = AttemptSuiteFactory([fake_1, fake_2], |
471 | 1990 | bootstrap_attempt=fake_bootstrap) | 2035 | bootstrap_attempt=fake_bootstrap) |
473 | 1991 | attempt_suite = AttemptSuite(factory, None, None) | 2036 | attempt_suite = AttemptSuite(factory, None, None, None) |
474 | 1992 | client = FakeJujuClient() | 2037 | client = FakeJujuClient() |
475 | 1993 | bs_manager = FakeBootstrapManager(client) | 2038 | bs_manager = FakeBootstrapManager(client) |
476 | 1994 | steps = list(attempt_suite._iter_bs_manager_steps( | 2039 | steps = list(attempt_suite._iter_bs_manager_steps( |
thank you.