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
1=== modified file 'c2dconfigutils/cu2dUpdateCi.py'
2--- c2dconfigutils/cu2dUpdateCi.py 2013-05-15 15:30:58 +0000
3+++ c2dconfigutils/cu2dUpdateCi.py 2013-05-22 13:14:27 +0000
4@@ -140,7 +140,7 @@
5 ctx['parameter_list'].append(parameter)
6
7 def process_project_config(self, project_name, project_config,
8- job_data):
9+ job_data, builder_job=False):
10 """ Generates the template context from a project configuration
11
12 :param project_name: the project name from the stack definition
13@@ -162,6 +162,14 @@
14 else:
15 project_config['hooks'] = stack_ppa_hook
16
17+ # Rename hooks parameter for builder jobs
18+ if builder_job and 'hooks' in project_config:
19+ # The hooks parameter used by the builder job must not have
20+ # the same name as the parent job. Otherwise, the builder job
21+ # will always inherit the hooks from the parent and builder
22+ # specific hooks specified in the stack file will be ignored.
23+ project_config['builder_hooks'] = project_config['hooks']
24+
25 for key in project_config:
26 data = project_config[key]
27
28@@ -260,7 +268,8 @@
29 else:
30 dict_union(build_config, data)
31 ctx = self.process_project_config(project_name,
32- build_config, job_data)
33+ build_config, job_data,
34+ builder_job=True)
35 build_name = '-'.join([job_base_name, config_name,
36 job_type])
37 build_list.append(build_name)
38
39=== modified file 'ci/jenkins-templates/mbs-pbuilder-config.xml.tmpl'
40--- ci/jenkins-templates/mbs-pbuilder-config.xml.tmpl 2013-04-26 15:47:24 +0000
41+++ ci/jenkins-templates/mbs-pbuilder-config.xml.tmpl 2013-05-22 13:14:27 +0000
42@@ -58,7 +58,7 @@
43 <command>{{ acquire_hook_script }}</command>
44 </hudson.tasks.Shell>
45 <com.ubuntu.builder.PBuilderPlugin>
46- <hooks>$hooks</hooks>
47+ <hooks>$builder_hooks</hooks>
48 <mainBranch>$landing_candidate</mainBranch>
49 <packagingBranch>{{ packaging_branch }}</packagingBranch>
50 <targetBranch>$target_branch</targetBranch>
51
52=== modified file 'ci/jenkins-templates/pbuilder-config.xml.tmpl'
53--- ci/jenkins-templates/pbuilder-config.xml.tmpl 2013-04-26 15:47:24 +0000
54+++ ci/jenkins-templates/pbuilder-config.xml.tmpl 2013-05-22 13:14:27 +0000
55@@ -48,7 +48,7 @@
56 <command>{{ acquire_hook_script }}</command>
57 </hudson.tasks.Shell>
58 <com.ubuntu.builder.PBuilderPlugin>
59- <hooks>$hooks</hooks>
60+ <hooks>$builder_hooks</hooks>
61 <mainBranch>$landing_candidate</mainBranch>
62 <packagingBranch>{{ packaging_branch }}</packagingBranch>
63 <targetBranch>$target_branch</targetBranch>
64
65=== modified file 'tests/test_cu2dUpdateCi.py'
66--- tests/test_cu2dUpdateCi.py 2013-05-15 15:30:58 +0000
67+++ tests/test_cu2dUpdateCi.py 2013-05-22 13:14:27 +0000
68@@ -211,6 +211,40 @@
69 job_data)
70 self.assertEqual(expected, actual)
71
72+ def test_project_config_parent_hooks(self):
73+ config = {'hooks': 'parent-hook'}
74+ expected = {'target_branch': 'lp:project',
75+ 'project_name': 'project',
76+ 'hooks': 'parent-hook',
77+ 'parameter_list': [
78+ JobParameter('hooks',
79+ 'parent-hook'),
80+ JobParameter('target_branch',
81+ 'lp:project'),
82+ JobParameter('project_name',
83+ 'project')]}
84+ actual = self.update_ci.process_project_config('project', config, {})
85+ self.assertEqual(expected, actual)
86+
87+ def test_project_config_builder_hooks(self):
88+ config = {'hooks': 'builder-hook'}
89+ expected = {'target_branch': 'lp:project',
90+ 'project_name': 'project',
91+ 'hooks': 'builder-hook',
92+ 'builder_hooks': 'builder-hook',
93+ 'parameter_list': [
94+ JobParameter('hooks',
95+ 'builder-hook'),
96+ JobParameter('target_branch',
97+ 'lp:project'),
98+ JobParameter('builder_hooks',
99+ 'builder-hook'),
100+ JobParameter('project_name',
101+ 'project')]}
102+ actual = self.update_ci.process_project_config('project', config, {},
103+ builder_job=True)
104+ self.assertEqual(expected, actual)
105+
106 def test_project_config_aggregate_tests(self):
107 config = {'aggregate_tests': 'generic-job'}
108 expected = {'target_branch': 'lp:project',
109@@ -385,11 +419,13 @@
110 'contact_email': 'address@email',
111 'distributions': 'raring,quantal,precise',
112 'ppa_target': 'ppa:autopilot/ppa',
113+ 'hooks': 'parent-hook',
114 'autolanding': {
115 'postbuild_job': 'autopilot-docs-upload',
116 'archive_artifacts': '**/output/*deb',
117 'configurations': {
118 'raring-amd64': {
119+ 'hooks': 'builder-hook',
120 'priority': 10000},
121 'raring-i386': {
122 'template': 'autopilot-config.xml.tmpl',
123@@ -490,8 +526,34 @@
124 child_params = [p for p in
125 child['ctx']['parameter_list']]
126 for p in parent_params:
127+ # Skip hooks as parent and child may differ
128+ if p.name == 'hooks':
129+ continue
130 self.assertIn(p, child_params)
131
132+ def test_parent_child_hooks(self):
133+ """Verifies that a child builder job has a unique hook parameter when
134+ hooks are specified for the builder job"""
135+ actual_name_list = [job['name'] for job in self.job_list]
136+ self.assertIn('autopilot-autolanding', actual_name_list)
137+ self.assertIn('autopilot-raring-amd64-autolanding', actual_name_list)
138+ self.assertIn('autopilot-raring-i386-autolanding', actual_name_list)
139+ count = 0
140+ for job in self.job_list:
141+ if job['name'] == 'autopilot-autolanding':
142+ self.assertEqual(job['ctx']['hooks'], 'parent-hook')
143+ count += 1
144+ if job['name'] == 'autopilot-raring-amd64-autolanding':
145+ self.assertEqual(job['ctx']['builder_hooks'], 'builder-hook')
146+ self.assertEqual(job['ctx']['hooks'], 'builder-hook')
147+ count += 1
148+ if job['name'] == 'autopilot-raring-i386-autolanding':
149+ self.assertEqual(job['ctx']['builder_hooks'], 'parent-hook')
150+ self.assertEqual(job['ctx']['hooks'], 'parent-hook')
151+ count += 1
152+ # Make sure no assertion groups were missed
153+ self.assertEqual(count, 3)
154+
155 def test_target_project(self):
156 job_list = []
157 target_project = 'autopilot'

Subscribers

People subscribed via source and target branches

to all changes: