Merge lp:~fginther/cupstream2distro-config/fix-pbuilder-hooks into lp:cupstream2distro-config

Proposed by Francis Ginther
Status: Merged
Approved by: Martin Mrazik
Approved revision: 333
Merged at revision: 340
Proposed branch: lp:~fginther/cupstream2distro-config/fix-pbuilder-hooks
Merge into: lp:cupstream2distro-config
Diff against target: 157 lines (+75/-4)
4 files modified
c2dconfigutils/cu2dUpdateCi.py (+11/-2)
ci/jenkins-templates/mbs-pbuilder-config.xml.tmpl (+1/-1)
ci/jenkins-templates/pbuilder-config.xml.tmpl (+1/-1)
tests/test_cu2dUpdateCi.py (+62/-0)
To merge this branch: bzr merge lp:~fginther/cupstream2distro-config/fix-pbuilder-hooks
Reviewer Review Type Date Requested Status
Martin Mrazik (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+164823@code.launchpad.net

Commit message

Use different jenkins parameter names to specify the hooks list for the parent and the child builder jobs. The $hooks value is always inherited from the parent job and as a result, it was not possible to specify unique hooks for the builder jobs using $hooks. The child builder jobs will use $builder_hooks instead.

Description of the change

Use different jenkins parameter names to specify the hooks list for the parent and the child builder jobs. The $hooks value is always inherited from the parent job and as a result, it was not possible to specify unique hooks for the builder jobs using $hooks. The child builder jobs will use $builder_hooks instead.

Some jobs (i.e. compiz and unity) have different hooks for specific pbuilder jobs. The idea was to use these different hooks to skip the coverage build for armhf and get a faster build. However, this is not working in practice because the builder jobs are always inheriting the $hooks value from the parent. The solution is to not use the $hooks parameter for the actual pbuilder hooks value, instead it uses $builder_hooks which contains the value generated at job deployment time and ignores the value of $hooks. This still allows a parent to pass a $hooks value to a non cu2d-config child job.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Martin Mrazik (mrazik) wrote :

I guess this is a matter of preference but I always get confused when I see just "True" somewhere:
34 + True)

Can you maybe change it to builder_job=True to improve the readability of the call?

This is not used anywhere (looks like a leftover from copy&paste):
135 + config = {
136 + 'hooks': 'parent-hook',
137 + 'configurations': {
138 + 'raring-amd64': {'node_label': 'pbuilder',
139 + 'hooks': 'child-only-hook'},
140 + 'raring-i386': {'node_label': 'pbuilder'}}}

Not sure if this is the error jenkins complains about but the following fails on my machine:

159 + self.assertEqual(count, 3)

I guess the following should be just +1? :
157 + count += 3

Other than it looks good.

review: Needs Fixing
333. By Francis Ginther

Fixed readability issues, removed some unused code and fixed the test_parent_child_hooks test.

Revision history for this message
Francis Ginther (fginther) wrote :

> I guess this is a matter of preference but I always get confused when I see
> just "True" somewhere:
> 34 + True)
>
> Can you maybe change it to builder_job=True to improve the readability of the
> call?

No problem.

> This is not used anywhere (looks like a leftover from copy&paste):
> 135 + config = {
> 136 + 'hooks': 'parent-hook',
> 137 + 'configurations': {
> 138 + 'raring-amd64': {'node_label': 'pbuilder',
> 139 + 'hooks': 'child-only-hook'},
> 140 + 'raring-i386': {'node_label': 'pbuilder'}}}
>

Removed.

> Not sure if this is the error jenkins complains about but the following fails
> on my machine:
>
> 159 + self.assertEqual(count, 3)
>
> I guess the following should be just +1? :
> 157 + count += 3
>

Oops, I had modified this to make sure it would catch a failure, then forgot to change it back. Fixed.

> Other than it looks good.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Martin Mrazik (mrazik) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'c2dconfigutils/cu2dUpdateCi.py'
--- c2dconfigutils/cu2dUpdateCi.py 2013-05-15 15:30:58 +0000
+++ c2dconfigutils/cu2dUpdateCi.py 2013-05-22 13:14:27 +0000
@@ -140,7 +140,7 @@
140 ctx['parameter_list'].append(parameter)140 ctx['parameter_list'].append(parameter)
141141
142 def process_project_config(self, project_name, project_config,142 def process_project_config(self, project_name, project_config,
143 job_data):143 job_data, builder_job=False):
144 """ Generates the template context from a project configuration144 """ Generates the template context from a project configuration
145145
146 :param project_name: the project name from the stack definition146 :param project_name: the project name from the stack definition
@@ -162,6 +162,14 @@
162 else:162 else:
163 project_config['hooks'] = stack_ppa_hook163 project_config['hooks'] = stack_ppa_hook
164164
165 # Rename hooks parameter for builder jobs
166 if builder_job and 'hooks' in project_config:
167 # The hooks parameter used by the builder job must not have
168 # the same name as the parent job. Otherwise, the builder job
169 # will always inherit the hooks from the parent and builder
170 # specific hooks specified in the stack file will be ignored.
171 project_config['builder_hooks'] = project_config['hooks']
172
165 for key in project_config:173 for key in project_config:
166 data = project_config[key]174 data = project_config[key]
167175
@@ -260,7 +268,8 @@
260 else:268 else:
261 dict_union(build_config, data)269 dict_union(build_config, data)
262 ctx = self.process_project_config(project_name,270 ctx = self.process_project_config(project_name,
263 build_config, job_data)271 build_config, job_data,
272 builder_job=True)
264 build_name = '-'.join([job_base_name, config_name,273 build_name = '-'.join([job_base_name, config_name,
265 job_type])274 job_type])
266 build_list.append(build_name)275 build_list.append(build_name)
267276
=== modified file 'ci/jenkins-templates/mbs-pbuilder-config.xml.tmpl'
--- ci/jenkins-templates/mbs-pbuilder-config.xml.tmpl 2013-04-26 15:47:24 +0000
+++ ci/jenkins-templates/mbs-pbuilder-config.xml.tmpl 2013-05-22 13:14:27 +0000
@@ -58,7 +58,7 @@
58 <command>{{ acquire_hook_script }}</command>58 <command>{{ acquire_hook_script }}</command>
59 </hudson.tasks.Shell>59 </hudson.tasks.Shell>
60 <com.ubuntu.builder.PBuilderPlugin>60 <com.ubuntu.builder.PBuilderPlugin>
61 <hooks>$hooks</hooks>61 <hooks>$builder_hooks</hooks>
62 <mainBranch>$landing_candidate</mainBranch>62 <mainBranch>$landing_candidate</mainBranch>
63 <packagingBranch>{{ packaging_branch }}</packagingBranch>63 <packagingBranch>{{ packaging_branch }}</packagingBranch>
64 <targetBranch>$target_branch</targetBranch>64 <targetBranch>$target_branch</targetBranch>
6565
=== modified file 'ci/jenkins-templates/pbuilder-config.xml.tmpl'
--- ci/jenkins-templates/pbuilder-config.xml.tmpl 2013-04-26 15:47:24 +0000
+++ ci/jenkins-templates/pbuilder-config.xml.tmpl 2013-05-22 13:14:27 +0000
@@ -48,7 +48,7 @@
48 <command>{{ acquire_hook_script }}</command>48 <command>{{ acquire_hook_script }}</command>
49 </hudson.tasks.Shell>49 </hudson.tasks.Shell>
50 <com.ubuntu.builder.PBuilderPlugin>50 <com.ubuntu.builder.PBuilderPlugin>
51 <hooks>$hooks</hooks>51 <hooks>$builder_hooks</hooks>
52 <mainBranch>$landing_candidate</mainBranch>52 <mainBranch>$landing_candidate</mainBranch>
53 <packagingBranch>{{ packaging_branch }}</packagingBranch>53 <packagingBranch>{{ packaging_branch }}</packagingBranch>
54 <targetBranch>$target_branch</targetBranch>54 <targetBranch>$target_branch</targetBranch>
5555
=== modified file 'tests/test_cu2dUpdateCi.py'
--- tests/test_cu2dUpdateCi.py 2013-05-15 15:30:58 +0000
+++ tests/test_cu2dUpdateCi.py 2013-05-22 13:14:27 +0000
@@ -211,6 +211,40 @@
211 job_data)211 job_data)
212 self.assertEqual(expected, actual)212 self.assertEqual(expected, actual)
213213
214 def test_project_config_parent_hooks(self):
215 config = {'hooks': 'parent-hook'}
216 expected = {'target_branch': 'lp:project',
217 'project_name': 'project',
218 'hooks': 'parent-hook',
219 'parameter_list': [
220 JobParameter('hooks',
221 'parent-hook'),
222 JobParameter('target_branch',
223 'lp:project'),
224 JobParameter('project_name',
225 'project')]}
226 actual = self.update_ci.process_project_config('project', config, {})
227 self.assertEqual(expected, actual)
228
229 def test_project_config_builder_hooks(self):
230 config = {'hooks': 'builder-hook'}
231 expected = {'target_branch': 'lp:project',
232 'project_name': 'project',
233 'hooks': 'builder-hook',
234 'builder_hooks': 'builder-hook',
235 'parameter_list': [
236 JobParameter('hooks',
237 'builder-hook'),
238 JobParameter('target_branch',
239 'lp:project'),
240 JobParameter('builder_hooks',
241 'builder-hook'),
242 JobParameter('project_name',
243 'project')]}
244 actual = self.update_ci.process_project_config('project', config, {},
245 builder_job=True)
246 self.assertEqual(expected, actual)
247
214 def test_project_config_aggregate_tests(self):248 def test_project_config_aggregate_tests(self):
215 config = {'aggregate_tests': 'generic-job'}249 config = {'aggregate_tests': 'generic-job'}
216 expected = {'target_branch': 'lp:project',250 expected = {'target_branch': 'lp:project',
@@ -385,11 +419,13 @@
385 'contact_email': 'address@email',419 'contact_email': 'address@email',
386 'distributions': 'raring,quantal,precise',420 'distributions': 'raring,quantal,precise',
387 'ppa_target': 'ppa:autopilot/ppa',421 'ppa_target': 'ppa:autopilot/ppa',
422 'hooks': 'parent-hook',
388 'autolanding': {423 'autolanding': {
389 'postbuild_job': 'autopilot-docs-upload',424 'postbuild_job': 'autopilot-docs-upload',
390 'archive_artifacts': '**/output/*deb',425 'archive_artifacts': '**/output/*deb',
391 'configurations': {426 'configurations': {
392 'raring-amd64': {427 'raring-amd64': {
428 'hooks': 'builder-hook',
393 'priority': 10000},429 'priority': 10000},
394 'raring-i386': {430 'raring-i386': {
395 'template': 'autopilot-config.xml.tmpl',431 'template': 'autopilot-config.xml.tmpl',
@@ -490,8 +526,34 @@
490 child_params = [p for p in526 child_params = [p for p in
491 child['ctx']['parameter_list']]527 child['ctx']['parameter_list']]
492 for p in parent_params:528 for p in parent_params:
529 # Skip hooks as parent and child may differ
530 if p.name == 'hooks':
531 continue
493 self.assertIn(p, child_params)532 self.assertIn(p, child_params)
494533
534 def test_parent_child_hooks(self):
535 """Verifies that a child builder job has a unique hook parameter when
536 hooks are specified for the builder job"""
537 actual_name_list = [job['name'] for job in self.job_list]
538 self.assertIn('autopilot-autolanding', actual_name_list)
539 self.assertIn('autopilot-raring-amd64-autolanding', actual_name_list)
540 self.assertIn('autopilot-raring-i386-autolanding', actual_name_list)
541 count = 0
542 for job in self.job_list:
543 if job['name'] == 'autopilot-autolanding':
544 self.assertEqual(job['ctx']['hooks'], 'parent-hook')
545 count += 1
546 if job['name'] == 'autopilot-raring-amd64-autolanding':
547 self.assertEqual(job['ctx']['builder_hooks'], 'builder-hook')
548 self.assertEqual(job['ctx']['hooks'], 'builder-hook')
549 count += 1
550 if job['name'] == 'autopilot-raring-i386-autolanding':
551 self.assertEqual(job['ctx']['builder_hooks'], 'parent-hook')
552 self.assertEqual(job['ctx']['hooks'], 'parent-hook')
553 count += 1
554 # Make sure no assertion groups were missed
555 self.assertEqual(count, 3)
556
495 def test_target_project(self):557 def test_target_project(self):
496 job_list = []558 job_list = []
497 target_project = 'autopilot'559 target_project = 'autopilot'

Subscribers

People subscribed via source and target branches

to all changes: