Merge lp:~pfalcon/linaro-android-frontend/reset-retention-for-official into lp:linaro-android-frontend

Proposed by Paul Sokolovsky
Status: Merged
Approved by: James Westby
Approved revision: 232
Merged at revision: 232
Proposed branch: lp:~pfalcon/linaro-android-frontend/reset-retention-for-official
Merge into: lp:linaro-android-frontend
Diff against target: 149 lines (+98/-2)
5 files modified
android_build/frontend/api.py (+18/-2)
android_build/tests/README (+3/-0)
android_build/tests/data/discard_builds_config.diff (+15/-0)
android_build/tests/data/discard_builds_config.xml (+46/-0)
android_build/tests/test_api.py (+16/-0)
To merge this branch: bzr merge lp:~pfalcon/linaro-android-frontend/reset-retention-for-official
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Michael Hudson-Doyle Pending
Alexander Sack Pending
Review via email: mp+72585@code.launchpad.net
To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

I'd appreciate a comment in the resetRetentionSettings about what
it's actually doing, as it's not particularly clear why deleting an
element named "logRotator" means that builds aren't deleted.

32 + "You are not allowed to create official build", status=403)

That should be "You are not allowed to create an official build."

Thanks,

James

review: Approve
Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

Fixed both.

233. By Paul Sokolovsky

Grammar fix.

234. By Paul Sokolovsky

resetRetentionSettings(): Add comment.

Revision history for this message
James Westby (james-w) wrote :

Looks great.

Thanks,

James

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'android_build/frontend/api.py'
--- android_build/frontend/api.py 2011-07-02 09:22:17 +0000
+++ android_build/frontend/api.py 2011-08-24 07:48:26 +0000
@@ -100,6 +100,19 @@
100 return etree.tostring(doc_root)100 return etree.tostring(doc_root)
101101
102102
103def resetRetentionSettings(configXml):
104 "Reset retention setting for a job to 'infinite retention'."
105 doc_root = etree.XML(configXml)
106 # Remove <logRotator> element, which corresponds to UI
107 # setting "Discard Old Builds".
108 try:
109 node = doc_root.xpath('//logRotator')[0]
110 except IndexError:
111 return configXml
112 doc_root.remove(node)
113 return etree.tostring(doc_root)
114
115
103def postConfig(url, configXml):116def postConfig(url, configXml):
104 try:117 try:
105 _authJenkins(url, configXml, {'Content-Type': 'text/xml'})118 _authJenkins(url, configXml, {'Content-Type': 'text/xml'})
@@ -170,10 +183,11 @@
170@builder_required183@builder_required
171def new(request):184def new(request):
172 try:185 try:
173 if request.POST.get('official', 'false') == 'true':186 is_official = request.POST.get('official', 'false') == 'true'
187 if is_official:
174 if not is_official_builder(request):188 if not is_official_builder(request):
175 return HttpResponse(189 return HttpResponse(
176 "You are not allowed to do that", status=403)190 "You are not allowed to create an official build", status=403)
177 ownerName = 'linaro-android'191 ownerName = 'linaro-android'
178 else:192 else:
179 ownerName = request.user.username193 ownerName = request.user.username
@@ -184,6 +198,8 @@
184 xml_base = getJobConfig(settings.TEMPLATE_JOB_NAME)198 xml_base = getJobConfig(settings.TEMPLATE_JOB_NAME)
185 if isinstance(xml_base, HttpResponse):199 if isinstance(xml_base, HttpResponse):
186 return xml_base200 return xml_base
201 if is_official:
202 xml_base = resetRetentionSettings(xml_base)
187 new_config = replaceConfigDefault(xml_base, request.POST['config'])203 new_config = replaceConfigDefault(xml_base, request.POST['config'])
188 resp = postConfig('createItem?name=' + new_job_name, new_config)204 resp = postConfig('createItem?name=' + new_job_name, new_config)
189 if resp:205 if resp:
190206
=== added directory 'android_build/tests'
=== added file 'android_build/tests/README'
--- android_build/tests/README 1970-01-01 00:00:00 +0000
+++ android_build/tests/README 2011-08-24 07:48:26 +0000
@@ -0,0 +1,3 @@
1To run tests, from top-level dir:
2
3DJANGO_SETTINGS_MODULE=android_build.settings nosetests android_build/tests/ -s
04
=== added directory 'android_build/tests/data'
=== added file 'android_build/tests/data/discard_builds_config.diff'
--- android_build/tests/data/discard_builds_config.diff 1970-01-01 00:00:00 +0000
+++ android_build/tests/data/discard_builds_config.diff 2011-08-24 07:48:26 +0000
@@ -0,0 +1,15 @@
1---
2+++
3@@ -1,12 +1,6 @@
4 <project>
5 <actions/>
6 <description/>
7- <logRotator>
8- <daysToKeep>30</daysToKeep>
9- <numToKeep>10</numToKeep>
10- <artifactDaysToKeep>-1</artifactDaysToKeep>
11- <artifactNumToKeep>-1</artifactNumToKeep>
12- </logRotator>
13 <keepDependencies>false</keepDependencies>
14 <properties>
15 <hudson.model.ParametersDefinitionProperty>
016
=== added file 'android_build/tests/data/discard_builds_config.xml'
--- android_build/tests/data/discard_builds_config.xml 1970-01-01 00:00:00 +0000
+++ android_build/tests/data/discard_builds_config.xml 2011-08-24 07:48:26 +0000
@@ -0,0 +1,46 @@
1<project>
2 <actions/>
3 <description/>
4 <logRotator>
5 <daysToKeep>30</daysToKeep>
6 <numToKeep>10</numToKeep>
7 <artifactDaysToKeep>-1</artifactDaysToKeep>
8 <artifactNumToKeep>-1</artifactNumToKeep>
9 </logRotator>
10 <keepDependencies>false</keepDependencies>
11 <properties>
12 <hudson.model.ParametersDefinitionProperty>
13 <parameterDefinitions>
14 <hudson.model.StringParameterDefinition>
15 <name>CONFIG</name>
16 <description/>
17 <defaultValue>TUFOSUZFU1RfUkVQTz1naXQ6Ly9odHRwOi8vYW5kcm9pZC5naXQua2VybmVsLm9yZy9wbGF0Zm9ybS9tYW5pZmVzdC5naXQKTUFOSUZFU1RfQlJBTkNIPW1hc3RlcgpUQVJHRVRfUFJPRFVDVD1mdWxsLWVuZw==</defaultValue>
18 </hudson.model.StringParameterDefinition>
19 </parameterDefinitions>
20 </hudson.model.ParametersDefinitionProperty>
21 </properties>
22 <scm class="hudson.scm.NullSCM"/>
23 <assignedNode>ec2</assignedNode>
24 <canRoam>false</canRoam>
25 <disabled>false</disabled>
26 <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
27 <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
28 <triggers class="vector"/>
29 <concurrentBuild>true</concurrentBuild>
30 <builders>
31 <hudson.tasks.Shell>
32 <command>rm -rf build-tools
33bzr get http://bazaar.launchpad.net/~linaro-infrastructure/linaro-android-build-tools/trunk build-tools
34build-tools/node/build us-east-1.ec2-git-mirror.linaro.org "$CONFIG"
35#build-tools/node/build "$HUDSON_URL" "$CONFIG"
36</command>
37 </hudson.tasks.Shell>
38 </builders>
39 <publishers>
40 <hudson.tasks.ArtifactArchiver>
41 <artifacts>build/out/target/*/*/*.img,build/out/target/*/*/*.tar.bz2,build/out/*.tar.bz2,build/out/*.xml,build/out/*.html</artifacts>
42 <latestOnly>false</latestOnly>
43 </hudson.tasks.ArtifactArchiver>
44 </publishers>
45 <buildWrappers/>
46</project>
0\ No newline at end of file47\ No newline at end of file
148
=== added file 'android_build/tests/test_api.py'
--- android_build/tests/test_api.py 1970-01-01 00:00:00 +0000
+++ android_build/tests/test_api.py 2011-08-24 07:48:26 +0000
@@ -0,0 +1,16 @@
1import os
2import difflib
3
4from android_build.frontend import api
5
6datadir = os.path.dirname(__file__) + "/data"
7
8def assert_diff(text1, text2, diff_file):
9 actual_diff = "".join(list(difflib.unified_diff(text1.splitlines(True), text2.splitlines(True))))
10 expected_diff = open(diff_file).read()
11 assert actual_diff == expected_diff
12
13def test_resetRetentionSettings():
14 in_text = open(datadir + "/discard_builds_config.xml").read()
15 out_text = api.resetRetentionSettings(in_text)
16 assert_diff(in_text, out_text, datadir + "/discard_builds_config.diff")

Subscribers

People subscribed via source and target branches