Merge lp:~fginther/cupstream2distro-config/independent-triggering into lp:cupstream2distro-config
- independent-triggering
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Francis Ginther |
Approved revision: | 843 |
Merged at revision: | 844 |
Proposed branch: | lp:~fginther/cupstream2distro-config/independent-triggering |
Merge into: | lp:cupstream2distro-config |
Diff against target: |
350 lines (+128/-52) 2 files modified
c2dconfigutils/cu2dTrigger.py (+37/-27) tests/test_cu2dTrigger.py (+91/-25) |
To merge this branch: | bzr merge lp:~fginther/cupstream2distro-config/independent-triggering |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Joe Talbott (community) | Approve | ||
Francis Ginther | Needs Resubmitting | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+189953@code.launchpad.net |
Commit message
Allow independent triggering of ci and autolanding jobs for entire stacks.
Description of the change
Allow independent triggering of ci and autolanding for entire stacks.
This primarily contains changes to the argument handling to change the behavior of the --trigger-ci and --trigger-
Here are examples of this in action:
http://
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
Joe Talbott (joetalbott) wrote : | # |
L97 here trigger_types will either be ['autolanding'] or ['ci'] but in other places I see trigger_types being set to ['autolanding', 'ci']. I might be missing some context.
Francis Ginther (fginther) wrote : | # |
> L97 here trigger_types will either be ['autolanding'] or ['ci'] but in other
> places I see trigger_types being set to ['autolanding', 'ci']. I might be
> missing some context.
Good catch. This
100 + else:
should be:
if args.trigger_ci:
I want to enable both types of jobs if the arguments are there.
Francis Ginther (fginther) : | # |
- 843. By Francis Ginther
-
Should be able to trigger autolanding and ci jobs, not either/or.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:843
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
Francis Ginther (fginther) : | # |
Preview Diff
1 | === modified file 'c2dconfigutils/cu2dTrigger.py' | |||
2 | --- c2dconfigutils/cu2dTrigger.py 2013-05-13 18:19:16 +0000 | |||
3 | +++ c2dconfigutils/cu2dTrigger.py 2013-10-08 21:15:00 +0000 | |||
4 | @@ -59,21 +59,25 @@ | |||
5 | 59 | 'Useful when using -c or -l ' + | 59 | 'Useful when using -c or -l ' + |
6 | 60 | '(default: {}).'.format( | 60 | '(default: {}).'.format( |
7 | 61 | self.DEFAULT_STACKS_CFG_PATH)) | 61 | self.DEFAULT_STACKS_CFG_PATH)) |
15 | 62 | parser.add_argument('-c', '--trigger-ci', | 62 | parser.add_argument('-b', '--branch', |
16 | 63 | default=None, | 63 | default=None, |
17 | 64 | help='trigger ci job on the defined target branch') | 64 | help='target source branch to search') |
18 | 65 | parser.add_argument('-l', '--trigger-autolanding', | 65 | parser.add_argument('-c', '--trigger-ci', action='store_true', |
19 | 66 | default=None, | 66 | default=False, |
20 | 67 | help='Trigger autolanding on the defined' + | 67 | help='trigger ci jobs') |
21 | 68 | ' target branch') | 68 | parser.add_argument('-l', '--trigger-autolanding', action='store_true', |
22 | 69 | default=False, | ||
23 | 70 | help='Trigger autolanding jobs') | ||
24 | 69 | parser.add_argument('stackcfg', nargs='?', | 71 | parser.add_argument('stackcfg', nargs='?', |
25 | 70 | help='Path to a configuration file for the stack', | 72 | help='Path to a configuration file for the stack', |
26 | 71 | default=None) | 73 | default=None) |
27 | 72 | args = parser.parse_args() | 74 | args = parser.parse_args() |
28 | 73 | 75 | ||
32 | 74 | if not args.stackcfg and \ | 76 | if not args.stackcfg and not args.branch: |
33 | 75 | not args.trigger_ci and not args.trigger_autolanding: | 77 | parser.error('Either -b/--branch or stackcfg must be defined') |
34 | 76 | parser.error('One of -c, -l or stackcfg must be defined') | 78 | if not args.trigger_ci and not args.trigger_autolanding: |
35 | 79 | parser.error('Must specify -c/--trigger-ci or ' | ||
36 | 80 | '-l/--trigger-autolanding or both') | ||
37 | 77 | return args | 81 | return args |
38 | 78 | 82 | ||
39 | 79 | def generate_trigger(self, project_name, project_config, job_type): | 83 | def generate_trigger(self, project_name, project_config, job_type): |
40 | @@ -98,7 +102,7 @@ | |||
41 | 98 | 'branch': branch, | 102 | 'branch': branch, |
42 | 99 | 'options': options} | 103 | 'options': options} |
43 | 100 | 104 | ||
45 | 101 | def process_stack(self, stack): | 105 | def process_stack(self, stack, trigger_types): |
46 | 102 | """ Generate a list of job triggers from the projects within a stack | 106 | """ Generate a list of job triggers from the projects within a stack |
47 | 103 | 107 | ||
48 | 104 | :param stack: dictionary with configuration of the stack | 108 | :param stack: dictionary with configuration of the stack |
49 | @@ -113,7 +117,7 @@ | |||
50 | 113 | project_config = copy.deepcopy(stack['ci_default']) | 117 | project_config = copy.deepcopy(stack['ci_default']) |
51 | 114 | dict_union(project_config, stack[section_name][project_name]) | 118 | dict_union(project_config, stack[section_name][project_name]) |
52 | 115 | 119 | ||
54 | 116 | for job_type in ['ci', 'autolanding']: | 120 | for job_type in trigger_types: |
55 | 117 | if project_config.get(job_type + '_template', None): | 121 | if project_config.get(job_type + '_template', None): |
56 | 118 | trigger_list.append(self.generate_trigger( | 122 | trigger_list.append(self.generate_trigger( |
57 | 119 | project_name, project_config, job_type)) | 123 | project_name, project_config, job_type)) |
58 | @@ -150,7 +154,8 @@ | |||
59 | 150 | else: | 154 | else: |
60 | 151 | return result | 155 | return result |
61 | 152 | 156 | ||
63 | 153 | def trigger_stack(self, default_config, stackcfg, plugin_path): | 157 | def trigger_stack(self, default_config, stackcfg, plugin_path, |
64 | 158 | trigger_types): | ||
65 | 154 | lock_name = self._get_lock_name(stackcfg) | 159 | lock_name = self._get_lock_name(stackcfg) |
66 | 155 | stackcfg = load_stack_cfg(stackcfg, default_config) | 160 | stackcfg = load_stack_cfg(stackcfg, default_config) |
67 | 156 | if not stackcfg: | 161 | if not stackcfg: |
68 | @@ -158,7 +163,7 @@ | |||
69 | 158 | return 1 | 163 | return 1 |
70 | 159 | trigger_list = [] | 164 | trigger_list = [] |
71 | 160 | if stackcfg['projects']: | 165 | if stackcfg['projects']: |
73 | 161 | trigger_list = self.process_stack(stackcfg) | 166 | trigger_list = self.process_stack(stackcfg, trigger_types) |
74 | 162 | 167 | ||
75 | 163 | for trigger in trigger_list: | 168 | for trigger in trigger_list: |
76 | 164 | self.trigger_job(plugin_path, trigger, lock_name) | 169 | self.trigger_job(plugin_path, trigger, lock_name) |
77 | @@ -192,10 +197,12 @@ | |||
78 | 192 | return None | 197 | return None |
79 | 193 | 198 | ||
80 | 194 | def trigger_project(self, plugin_path, default_config, trigger_branch, | 199 | def trigger_project(self, plugin_path, default_config, trigger_branch, |
82 | 195 | stackcfg_dir, trigger_type): | 200 | stackcfg_dir, trigger_types): |
83 | 196 | 201 | ||
86 | 197 | trigger = self.get_trigger_for_target(default_config, trigger_branch, | 202 | for job_type in trigger_types: |
87 | 198 | stackcfg_dir, trigger_type) | 203 | trigger = self.get_trigger_for_target(default_config, |
88 | 204 | trigger_branch, | ||
89 | 205 | stackcfg_dir, job_type) | ||
90 | 199 | if not trigger: | 206 | if not trigger: |
91 | 200 | return 1 | 207 | return 1 |
92 | 201 | self.trigger_job(plugin_path, trigger, lock_name='target-branch') | 208 | self.trigger_job(plugin_path, trigger, lock_name='target-branch') |
93 | @@ -207,16 +214,19 @@ | |||
94 | 207 | 214 | ||
95 | 208 | set_logging(args.debug) | 215 | set_logging(args.debug) |
96 | 209 | default_config = load_default_cfg(default_config_path) | 216 | default_config = load_default_cfg(default_config_path) |
97 | 217 | trigger_types = [] | ||
98 | 218 | if args.trigger_autolanding: | ||
99 | 219 | trigger_types.append('autolanding') | ||
100 | 220 | if args.trigger_ci: | ||
101 | 221 | trigger_types.append('ci') | ||
102 | 210 | if args.stackcfg: | 222 | if args.stackcfg: |
103 | 211 | return self.trigger_stack(default_config, | 223 | return self.trigger_stack(default_config, |
104 | 212 | args.stackcfg, | 224 | args.stackcfg, |
115 | 213 | args.plugin_path) | 225 | args.plugin_path, |
116 | 214 | if args.trigger_autolanding: | 226 | trigger_types) |
117 | 215 | trigger_type = 'autolanding' | 227 | if args.branch and args.stackcfg_dir: |
118 | 216 | trigger_branch = args.trigger_autolanding | 228 | return self.trigger_project(args.plugin_path, default_config, |
119 | 217 | else: | 229 | args.branch, args.stackcfg_dir, |
120 | 218 | trigger_type = 'ci' | 230 | trigger_types) |
121 | 219 | trigger_branch = args.trigger_ci | 231 | logging.error('Invalid arguments') |
122 | 220 | return self.trigger_project(args.plugin_path, default_config, | 232 | return -1 |
113 | 221 | trigger_branch, args.stackcfg_dir, | ||
114 | 222 | trigger_type) | ||
123 | 223 | 233 | ||
124 | === modified file 'tests/test_cu2dTrigger.py' | |||
125 | --- tests/test_cu2dTrigger.py 2013-05-15 16:41:46 +0000 | |||
126 | +++ tests/test_cu2dTrigger.py 2013-10-08 21:15:00 +0000 | |||
127 | @@ -107,9 +107,10 @@ | |||
128 | 107 | 107 | ||
129 | 108 | def setUp(self): | 108 | def setUp(self): |
130 | 109 | self.jt = JobTrigger() | 109 | self.jt = JobTrigger() |
131 | 110 | self.trigger_types = ['ci', 'autolanding'] | ||
132 | 110 | 111 | ||
133 | 111 | def test_process_stack(self): | 112 | def test_process_stack(self): |
135 | 112 | ret = self.jt.process_stack(self.stack) | 113 | ret = self.jt.process_stack(self.stack, self.trigger_types) |
136 | 113 | self.assertEqual(self.expected_result, ret) | 114 | self.assertEqual(self.expected_result, ret) |
137 | 114 | 115 | ||
138 | 115 | 116 | ||
139 | @@ -189,6 +190,7 @@ | |||
140 | 189 | self.plugin_path = '/tmp' | 190 | self.plugin_path = '/tmp' |
141 | 190 | self.stack_cfg = {'projects': {'foo': {}, | 191 | self.stack_cfg = {'projects': {'foo': {}, |
142 | 191 | 'bar': {}}} | 192 | 'bar': {}}} |
143 | 193 | self.trigger_types = ['ci', 'autolanding'] | ||
144 | 192 | self.jt = JobTrigger() | 194 | self.jt = JobTrigger() |
145 | 193 | self.jt.process_stack = MagicMock(return_value=['trigger']) | 195 | self.jt.process_stack = MagicMock(return_value=['trigger']) |
146 | 194 | self.jt.trigger_job = MagicMock() | 196 | self.jt.trigger_job = MagicMock() |
147 | @@ -198,9 +200,10 @@ | |||
148 | 198 | """Verifiy jobs are triggered for a valid stack""" | 200 | """Verifiy jobs are triggered for a valid stack""" |
149 | 199 | load_stack_cfg.return_value = self.stack_cfg | 201 | load_stack_cfg.return_value = self.stack_cfg |
150 | 200 | ret = self.jt.trigger_stack(self.default_config, self.stack_cfg_name, | 202 | ret = self.jt.trigger_stack(self.default_config, self.stack_cfg_name, |
152 | 201 | self.plugin_path) | 203 | self.plugin_path, self.trigger_types) |
153 | 202 | load_stack_cfg.assert_called_with('stacks/head/foobar.cfg', {}) | 204 | load_stack_cfg.assert_called_with('stacks/head/foobar.cfg', {}) |
155 | 203 | self.jt.process_stack.assert_called_with(self.stack_cfg) | 205 | self.jt.process_stack.assert_called_with(self.stack_cfg, |
156 | 206 | self.trigger_types) | ||
157 | 204 | self.jt.trigger_job.assert_called_with(self.plugin_path, 'trigger', | 207 | self.jt.trigger_job.assert_called_with(self.plugin_path, 'trigger', |
158 | 205 | 'head-foobar.cfg') | 208 | 'head-foobar.cfg') |
159 | 206 | self.assertEqual(ret, 0) | 209 | self.assertEqual(ret, 0) |
160 | @@ -210,7 +213,7 @@ | |||
161 | 210 | """Verify no jobs are triggered when stack file fails to load""" | 213 | """Verify no jobs are triggered when stack file fails to load""" |
162 | 211 | load_stack_cfg.return_value = False | 214 | load_stack_cfg.return_value = False |
163 | 212 | ret = self.jt.trigger_stack(self.default_config, self.stack_cfg_name, | 215 | ret = self.jt.trigger_stack(self.default_config, self.stack_cfg_name, |
165 | 213 | self.plugin_path) | 216 | self.plugin_path, self.trigger_types) |
166 | 214 | load_stack_cfg.assert_called_with('stacks/head/foobar.cfg', {}) | 217 | load_stack_cfg.assert_called_with('stacks/head/foobar.cfg', {}) |
167 | 215 | self.assertFalse(self.jt.process_stack.called) | 218 | self.assertFalse(self.jt.process_stack.called) |
168 | 216 | self.assertFalse(self.jt.trigger_job.called) | 219 | self.assertFalse(self.jt.trigger_job.called) |
169 | @@ -221,7 +224,7 @@ | |||
170 | 221 | """Verify no jobs are triggered when no project section""" | 224 | """Verify no jobs are triggered when no project section""" |
171 | 222 | load_stack_cfg.return_value = {} | 225 | load_stack_cfg.return_value = {} |
172 | 223 | ret = self.jt.trigger_stack(self.default_config, self.stack_cfg_name, | 226 | ret = self.jt.trigger_stack(self.default_config, self.stack_cfg_name, |
174 | 224 | self.plugin_path) | 227 | self.plugin_path, self.trigger_types) |
175 | 225 | load_stack_cfg.assert_called_with('stacks/head/foobar.cfg', {}) | 228 | load_stack_cfg.assert_called_with('stacks/head/foobar.cfg', {}) |
176 | 226 | self.assertFalse(self.jt.process_stack.called) | 229 | self.assertFalse(self.jt.process_stack.called) |
177 | 227 | self.assertFalse(self.jt.trigger_job.called) | 230 | self.assertFalse(self.jt.trigger_job.called) |
178 | @@ -234,7 +237,7 @@ | |||
179 | 234 | 'to_transition': {'foo': {}, | 237 | 'to_transition': {'foo': {}, |
180 | 235 | 'bar': {}}} | 238 | 'bar': {}}} |
181 | 236 | ret = self.jt.trigger_stack(self.default_config, self.stack_cfg_name, | 239 | ret = self.jt.trigger_stack(self.default_config, self.stack_cfg_name, |
183 | 237 | self.plugin_path) | 240 | self.plugin_path, self.trigger_types) |
184 | 238 | load_stack_cfg.assert_called_with('stacks/head/foobar.cfg', {}) | 241 | load_stack_cfg.assert_called_with('stacks/head/foobar.cfg', {}) |
185 | 239 | self.assertFalse(self.jt.process_stack.called) | 242 | self.assertFalse(self.jt.process_stack.called) |
186 | 240 | self.assertFalse(self.jt.trigger_job.called) | 243 | self.assertFalse(self.jt.trigger_job.called) |
187 | @@ -246,9 +249,10 @@ | |||
188 | 246 | load_stack_cfg.return_value = self.stack_cfg | 249 | load_stack_cfg.return_value = self.stack_cfg |
189 | 247 | self.jt.process_stack = MagicMock(return_value=[]) | 250 | self.jt.process_stack = MagicMock(return_value=[]) |
190 | 248 | ret = self.jt.trigger_stack(self.default_config, self.stack_cfg_name, | 251 | ret = self.jt.trigger_stack(self.default_config, self.stack_cfg_name, |
192 | 249 | self.plugin_path) | 252 | self.plugin_path, self.trigger_types) |
193 | 250 | load_stack_cfg.assert_called_with('stacks/head/foobar.cfg', {}) | 253 | load_stack_cfg.assert_called_with('stacks/head/foobar.cfg', {}) |
195 | 251 | self.jt.process_stack.assert_called_with(self.stack_cfg) | 254 | self.jt.process_stack.assert_called_with(self.stack_cfg, |
196 | 255 | self.trigger_types) | ||
197 | 252 | self.assertFalse(self.jt.trigger_job.called) | 256 | self.assertFalse(self.jt.trigger_job.called) |
198 | 253 | self.assertEqual(ret, 0) | 257 | self.assertEqual(ret, 0) |
199 | 254 | 258 | ||
200 | @@ -256,15 +260,18 @@ | |||
201 | 256 | class TestTriggerBranch(TestWithScenarios, TestCase): | 260 | class TestTriggerBranch(TestWithScenarios, TestCase): |
202 | 257 | scenarios = [ | 261 | scenarios = [ |
203 | 258 | ('ci', | 262 | ('ci', |
205 | 259 | {'trigger_type': 'ci', | 263 | {'trigger_type': ['ci'], |
206 | 264 | 'job_type': 'ci', | ||
207 | 260 | 'fasttrack': True, | 265 | 'fasttrack': True, |
208 | 261 | 'options': ['--trigger-ci']}), | 266 | 'options': ['--trigger-ci']}), |
209 | 262 | ('autolanding-fasttrack', | 267 | ('autolanding-fasttrack', |
211 | 263 | {'trigger_type': 'autolanding', | 268 | {'trigger_type': ['autolanding'], |
212 | 269 | 'job_type': 'autolanding', | ||
213 | 264 | 'fasttrack': True, | 270 | 'fasttrack': True, |
214 | 265 | 'options': ['--autoland', '--fasttrack']}), | 271 | 'options': ['--autoland', '--fasttrack']}), |
215 | 266 | ('autolanding-nofasttrack', | 272 | ('autolanding-nofasttrack', |
217 | 267 | {'trigger_type': 'autolanding', | 273 | {'trigger_type': ['autolanding'], |
218 | 274 | 'job_type': 'autolanding', | ||
219 | 268 | 'fasttrack': False, | 275 | 'fasttrack': False, |
220 | 269 | 'options': ['--autoland']}), | 276 | 'options': ['--autoland']}), |
221 | 270 | ] | 277 | ] |
222 | @@ -284,7 +291,7 @@ | |||
223 | 284 | self.trigger_type) | 291 | self.trigger_type) |
224 | 285 | jt.get_trigger_for_target.assert_called_once_with( | 292 | jt.get_trigger_for_target.assert_called_once_with( |
225 | 286 | self.default_config, self.target_branch, | 293 | self.default_config, self.target_branch, |
227 | 287 | self.stackcfg_dir, self.trigger_type) | 294 | self.stackcfg_dir, self.job_type) |
228 | 288 | jt.trigger_job.assert_called_once_with(self.plugin_path, trigger, | 295 | jt.trigger_job.assert_called_once_with(self.plugin_path, trigger, |
229 | 289 | lock_name='target-branch') | 296 | lock_name='target-branch') |
230 | 290 | self.assertEqual(ret, 0) | 297 | self.assertEqual(ret, 0) |
231 | @@ -322,9 +329,9 @@ | |||
232 | 322 | trigger = jt.get_trigger_for_target(self.default_config, | 329 | trigger = jt.get_trigger_for_target(self.default_config, |
233 | 323 | self.target_branch, | 330 | self.target_branch, |
234 | 324 | self.stackcfg_dir, | 331 | self.stackcfg_dir, |
236 | 325 | self.trigger_type) | 332 | self.job_type) |
237 | 326 | expected_trigger = { | 333 | expected_trigger = { |
239 | 327 | 'name': 'branch-{}'.format(self.trigger_type), | 334 | 'name': 'branch-{}'.format(self.job_type), |
240 | 328 | 'branch': self.target_branch, | 335 | 'branch': self.target_branch, |
241 | 329 | 'options': self.options | 336 | 'options': self.options |
242 | 330 | } | 337 | } |
243 | @@ -367,12 +374,38 @@ | |||
244 | 367 | 374 | ||
245 | 368 | @patch('c2dconfigutils.cu2dTrigger.load_default_cfg') | 375 | @patch('c2dconfigutils.cu2dTrigger.load_default_cfg') |
246 | 369 | def test_stackcfg_defined(self, load_default_cfg): | 376 | def test_stackcfg_defined(self, load_default_cfg): |
247 | 377 | sys_argv = ['./command', '--trigger-ci', '../stacks/head/stack.cfg'] | ||
248 | 378 | with patch('sys.argv', sys_argv): | ||
249 | 379 | jt = JobTrigger() | ||
250 | 380 | jt.trigger_stack = MagicMock() | ||
251 | 381 | jt('') | ||
252 | 382 | jt.trigger_stack.assert_called_once() | ||
253 | 383 | |||
254 | 384 | @patch('c2dconfigutils.cu2dTrigger.load_default_cfg') | ||
255 | 385 | def test_trigger_ci_and_autolanding_stack(self, load_default_cfg): | ||
256 | 386 | load_default_cfg.return_value = {} | ||
257 | 387 | sys_argv = ['./command', '--trigger-ci', '--trigger-autolanding', | ||
258 | 388 | '../stacks/head/stack.cfg'] | ||
259 | 389 | with patch('sys.argv', sys_argv): | ||
260 | 390 | jt = JobTrigger() | ||
261 | 391 | jt.trigger_stack = MagicMock() | ||
262 | 392 | jt('') | ||
263 | 393 | jt.trigger_stack.assert_called_once_with( | ||
264 | 394 | {}, '../stacks/head/stack.cfg', | ||
265 | 395 | JobTrigger.DEFAULT_PLUGIN_PATH, | ||
266 | 396 | ['autolanding', 'ci']) | ||
267 | 397 | |||
268 | 398 | @patch('c2dconfigutils.cu2dTrigger.load_default_cfg') | ||
269 | 399 | def test_missing_type(self, load_default_cfg): | ||
270 | 370 | sys_argv = ['./command', '../stacks/head/stack.cfg'] | 400 | sys_argv = ['./command', '../stacks/head/stack.cfg'] |
271 | 371 | with patch('sys.argv', sys_argv): | 401 | with patch('sys.argv', sys_argv): |
272 | 372 | jt = JobTrigger() | 402 | jt = JobTrigger() |
273 | 373 | jt.trigger_stack = MagicMock() | 403 | jt.trigger_stack = MagicMock() |
276 | 374 | jt('') | 404 | try: |
277 | 375 | jt.trigger_stack.assert_called_once() | 405 | jt('') |
278 | 406 | except SystemExit: | ||
279 | 407 | exception = True | ||
280 | 408 | self.assertTrue(exception) | ||
281 | 376 | 409 | ||
282 | 377 | @patch('c2dconfigutils.cu2dTrigger.load_default_cfg') | 410 | @patch('c2dconfigutils.cu2dTrigger.load_default_cfg') |
283 | 378 | def test_trigger_autolanding(self, load_default_cfg): | 411 | def test_trigger_autolanding(self, load_default_cfg): |
284 | @@ -381,13 +414,13 @@ | |||
285 | 381 | plugin_path = '/plugin/path' | 414 | plugin_path = '/plugin/path' |
286 | 382 | cfg_dir = '../stacks' | 415 | cfg_dir = '../stacks' |
287 | 383 | sys_argv = ['./command', '--trigger-autolanding', | 416 | sys_argv = ['./command', '--trigger-autolanding', |
289 | 384 | branch, '-p', plugin_path, '-D', cfg_dir] | 417 | '--branch', branch, '-p', plugin_path, '-D', cfg_dir] |
290 | 385 | with patch('sys.argv', sys_argv): | 418 | with patch('sys.argv', sys_argv): |
291 | 386 | jt = JobTrigger() | 419 | jt = JobTrigger() |
292 | 387 | jt.trigger_project = MagicMock() | 420 | jt.trigger_project = MagicMock() |
293 | 388 | jt('') | 421 | jt('') |
294 | 389 | jt.trigger_project.assert_called_once_with(plugin_path, {}, branch, | 422 | jt.trigger_project.assert_called_once_with(plugin_path, {}, branch, |
296 | 390 | cfg_dir, 'autolanding') | 423 | cfg_dir, ['autolanding']) |
297 | 391 | 424 | ||
298 | 392 | @patch('c2dconfigutils.cu2dTrigger.load_default_cfg') | 425 | @patch('c2dconfigutils.cu2dTrigger.load_default_cfg') |
299 | 393 | def test_trigger_ci(self, load_default_cfg): | 426 | def test_trigger_ci(self, load_default_cfg): |
300 | @@ -396,10 +429,43 @@ | |||
301 | 396 | plugin_path = '/plugin/path' | 429 | plugin_path = '/plugin/path' |
302 | 397 | cfg_dir = '../stacks' | 430 | cfg_dir = '../stacks' |
303 | 398 | sys_argv = ['./command', '--trigger-ci', | 431 | sys_argv = ['./command', '--trigger-ci', |
311 | 399 | branch, '-p', plugin_path, '-D', cfg_dir] | 432 | '--branch', branch, '-p', plugin_path, '-D', cfg_dir] |
312 | 400 | with patch('sys.argv', sys_argv): | 433 | with patch('sys.argv', sys_argv): |
313 | 401 | jt = JobTrigger() | 434 | jt = JobTrigger() |
314 | 402 | jt.trigger_project = MagicMock() | 435 | jt.trigger_project = MagicMock() |
315 | 403 | jt('') | 436 | jt('') |
316 | 404 | jt.trigger_project.assert_called_once_with(plugin_path, {}, branch, | 437 | jt.trigger_project.assert_called_once_with(plugin_path, {}, branch, |
317 | 405 | cfg_dir, 'ci') | 438 | cfg_dir, ['ci']) |
318 | 439 | |||
319 | 440 | @patch('c2dconfigutils.cu2dTrigger.load_default_cfg') | ||
320 | 441 | def test_trigger_ci_and_autolanding_branch(self, load_default_cfg): | ||
321 | 442 | load_default_cfg.return_value = {} | ||
322 | 443 | branch = 'lp:branch' | ||
323 | 444 | plugin_path = '/plugin/path' | ||
324 | 445 | cfg_dir = '../stacks' | ||
325 | 446 | sys_argv = ['./command', '--trigger-ci', '--trigger-autolanding', | ||
326 | 447 | '--branch', branch, '-p', plugin_path, '-D', cfg_dir] | ||
327 | 448 | with patch('sys.argv', sys_argv): | ||
328 | 449 | jt = JobTrigger() | ||
329 | 450 | jt.trigger_project = MagicMock() | ||
330 | 451 | jt('') | ||
331 | 452 | jt.trigger_project.assert_called_once_with(plugin_path, {}, branch, | ||
332 | 453 | cfg_dir, | ||
333 | 454 | ['autolanding', 'ci']) | ||
334 | 455 | |||
335 | 456 | @patch('c2dconfigutils.cu2dTrigger.load_default_cfg') | ||
336 | 457 | def test_trigger_ci_missing_branch(self, load_default_cfg): | ||
337 | 458 | load_default_cfg.return_value = {} | ||
338 | 459 | branch = 'lp:branch' | ||
339 | 460 | plugin_path = '/plugin/path' | ||
340 | 461 | cfg_dir = '../stacks' | ||
341 | 462 | sys_argv = ['./command', '--trigger-ci', | ||
342 | 463 | '-p', plugin_path, '-D', cfg_dir] | ||
343 | 464 | with patch('sys.argv', sys_argv): | ||
344 | 465 | jt = JobTrigger() | ||
345 | 466 | jt.trigger_project = MagicMock() | ||
346 | 467 | try: | ||
347 | 468 | jt('') | ||
348 | 469 | except SystemExit: | ||
349 | 470 | exception = True | ||
350 | 471 | self.assertTrue(exception) |
PASSED: Continuous integration, rev:842 jenkins. qa.ubuntu. com/job/ cupstream2distr o-config- ci/547/ jenkins. qa.ubuntu. com/job/ cupstream2distr o-config- saucy-amd64- ci/345
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild: 10.97.0. 26:8080/ job/cupstream2d istro-config- ci/547/ rebuild
http://