Merge lp:~ce-infrastructure/offspring/fix-offspring-dec2011-regressions into lp:offspring

Proposed by Cody A.W. Somerville
Status: Merged
Approved by: Cody A.W. Somerville
Approved revision: 137
Merged at revision: 135
Proposed branch: lp:~ce-infrastructure/offspring/fix-offspring-dec2011-regressions
Merge into: lp:offspring
Diff against target: 190 lines (+50/-20)
5 files modified
lib/offspring/master/scripts/publish_pending_releases.py (+12/-10)
lib/offspring/master/scripts/sync_launchpad_project_milestones.py (+5/-4)
lib/offspring/web/queuemanager/templatetags/lexbuilder_helpers.py (+5/-4)
lib/offspring/web/queuemanager/tests/test_templatetags.py (+26/-0)
setup.py (+2/-2)
To merge this branch: bzr merge lp:~ce-infrastructure/offspring/fix-offspring-dec2011-regressions
Reviewer Review Type Date Requested Status
Timothy R. Chavez Approve
Review via email: mp+102755@code.launchpad.net

Description of the change

This branch fixes a number of regressions that were introduced in late 2011 - how configuration in Offspring was changed but not all consumers of the API were updated and some functions that are console_entry shell scripts (setup tools thing) were moved but setup.py was not updated.

This branch also adds a (simple) test for the link_results templatetag which is responsible for generating the link to build results for the web front-end.

To post a comment you must log in.
Revision history for this message
Timothy R. Chavez (timrchavez) wrote :

Ok...

All web tests passed, ensure the patch covered all places needing to be replaced,

grep "config.web" -R * | wc -l
3
tim@burrito:~/offspring-regressions$ !564
grep "config.publisher" -R * | wc -l
9
tim@burrito:~/offspring-regressions$ !567
grep "config.web" -R * | wc -l
3
tim@burrito:~/offspring-regressions$ bzr merge lp:~ce-infrastructure/offspring/fix-offspring-dec2011-regressions
+N lib/offspring/web/queuemanager/tests/test_templatetags.py
 M lib/offspring/master/scripts/publish_pending_releases.py
 M lib/offspring/master/scripts/sync_launchpad_project_milestones.py
 M lib/offspring/web/queuemanager/templatetags/lexbuilder_helpers.py
 M setup.py
All changes applied successfully.
tim@burrito:~/offspring-regressions$ grep "config.web" -R * | wc -l
0
tim@burrito:~/offspring-regressions$ grep "config.publisher" -R * | wc -l
0
tim@burrito:~/offspring-regressions$ grep "config.web" -R * | wc -l
0

I also ran sync_launchpad_project_milestones.run() from the Django shell without issue.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/offspring/master/scripts/publish_pending_releases.py'
2--- lib/offspring/master/scripts/publish_pending_releases.py 2011-06-16 20:21:28 +0000
3+++ lib/offspring/master/scripts/publish_pending_releases.py 2012-04-19 19:48:22 +0000
4@@ -25,9 +25,11 @@
5 Store
6 )
7
8-from offspring import config
9+from offspring.config import get_configuration
10 from offspring.master.models import Release
11
12+config = get_configuration()
13+
14 def publish_tree(src, dst):
15 names = os.listdir(src)
16 try:
17@@ -44,25 +46,25 @@
18 # Do not publish development signatures.
19 continue
20 elif (srcname.endswith('sums.txt') and
21- os.path.exists(config.publisher("signer_script"))):
22+ os.path.exists(config.get('publisher', "signer_script"))):
23 # Copy file into signer files directory.
24 shutil.copyfile(
25 srcname,
26- os.path.join(config.publisher("signer_files"), name))
27+ os.path.join(config.get('publisher', "signer_files"), name))
28 # Execute the signer script to have files signed.
29- os.system(config.publisher("signer_script"))
30+ os.system(config.get('publisher', "signer_script"))
31 # Remove the file we copied into the signer directory.
32 os.remove(
33- os.path.join(config.publisher("signer_files"), name))
34+ os.path.join(config.get('publisher', "signer_files"), name))
35 # Move the signed file to the destination.
36 shutil.move(
37 os.path.join(
38- config.publisher("signer_results"), "%s.asc" % name
39+ config.get('publisher', "signer_results"), "%s.asc" % name
40 ), "%s.asc" % dstname)
41 shutil.copyfile(srcname, dstname)
42
43 def run():
44- database = create_database(config.publisher("db"))
45+ database = create_database(config.get('publisher', "db"))
46 store = Store(database)
47 for release in store.find(Release,
48 Release.status == Release.STATUS_PENDING):
49@@ -71,11 +73,11 @@
50 (release.name, release.build.project))
51 sys.stdout.flush()
52 images_directory = "%s/images" % release.build.result_directory(
53- base_dir=config.publisher('development_pool'))
54+ base_dir=config.get('publisher', 'development_pool'))
55 project_directory = "%s/project" % release.build.result_directory(
56- base_dir=config.publisher('development_pool'))
57+ base_dir=config.get('publisher', 'development_pool'))
58 release_directory = release.result_directory(
59- base_dir=config.publisher('production_pool'))
60+ base_dir=config.get('publisher', 'production_pool'))
61 # images
62 if os.path.exists(images_directory):
63 try:
64
65=== modified file 'lib/offspring/master/scripts/sync_launchpad_project_milestones.py'
66--- lib/offspring/master/scripts/sync_launchpad_project_milestones.py 2010-11-30 18:55:17 +0000
67+++ lib/offspring/master/scripts/sync_launchpad_project_milestones.py 2012-04-19 19:48:22 +0000
68@@ -10,7 +10,7 @@
69 from launchpadlib.uris import LPNET_SERVICE_ROOT
70 from storm.locals import create_database, Store
71
72-from offspring import config
73+from offspring.config import get_configuration
74 from offspring.master.models import (
75 LaunchpadProject,
76 LaunchpadProjectMilestone,
77@@ -19,19 +19,20 @@
78
79 def run():
80 # Setup connection to launchpad
81+ config = get_configuration()
82 cachedir = os.path.expanduser("~/.launchpadlib/cache/")
83 credentials = Credentials()
84 try:
85- credentials.load(open(config.master("launchpad_oauth")))
86+ credentials.load(open(config.get("master", "launchpad_oauth")))
87 launchpad = Launchpad(credentials, LPNET_SERVICE_ROOT)
88 except:
89 launchpad = Launchpad.get_token_and_login(
90 'Offspring Image Build System', LPNET_SERVICE_ROOT, cachedir)
91 launchpad.credentials.save(
92- file(config.master("launchpad_oauth"), "w"))
93+ file(config.get("master", "launchpad_oauth"), "w"))
94
95 # Setup connection to database
96- database = create_database(config.master("db"))
97+ database = create_database(config.get("master", "db"))
98 store = Store(database)
99
100 for launchpad_project in store.find(LaunchpadProject):
101
102=== modified file 'lib/offspring/web/queuemanager/templatetags/lexbuilder_helpers.py'
103--- lib/offspring/web/queuemanager/templatetags/lexbuilder_helpers.py 2010-11-29 08:27:24 +0000
104+++ lib/offspring/web/queuemanager/templatetags/lexbuilder_helpers.py 2012-04-19 19:48:22 +0000
105@@ -6,10 +6,11 @@
106 from django import template
107 from django.template.defaultfilters import stringfilter
108
109-from offspring import config
110+from offspring.config import get_configuration
111 from offspring.web.queuemanager.models import Project
112 from offspring.slave import LexbuilderSlave
113
114+config = get_configuration()
115 register = template.Library()
116
117 @register.filter
118@@ -17,7 +18,7 @@
119 def generate_devel_sourceslist(projectName):
120 try:
121 project = Project.objects.get(name=projectName)
122- projectArchiveURI = config.web("archive_uri")
123+ projectArchiveURI = config.get("web", "archive_uri")
124 except:
125 return ""
126
127@@ -44,7 +45,7 @@
128 @stringfilter
129 def link_results(projectName, buildName=None):
130 try:
131- base_uri = config.web("build_results_uri")
132+ base_uri = config.get("web", "build_results_uri")
133 except:
134 return ""
135
136@@ -52,7 +53,7 @@
137 try:
138 date, buildCount = buildName.rsplit("-", 1)
139 except:
140- return config.web("build_results_uri")
141+ return config.get("web", "build_results_uri")
142 return "%s/%s/%s/%s" % (base_uri, projectName, date, buildCount)
143 else:
144 return "%s/%s" % (base_uri, projectName)
145
146=== added file 'lib/offspring/web/queuemanager/tests/test_templatetags.py'
147--- lib/offspring/web/queuemanager/tests/test_templatetags.py 1970-01-01 00:00:00 +0000
148+++ lib/offspring/web/queuemanager/tests/test_templatetags.py 2012-04-19 19:48:22 +0000
149@@ -0,0 +1,26 @@
150+# Copyright 2012 Canonical Ltd. This software is licensed under the
151+# GNU Affero General Public License version 3 (see the file LICENSE).
152+
153+from django.test import TestCase
154+
155+from offspring.config import get_configuration
156+from offspring.web.queuemanager.templatetags.lexbuilder_helpers import (
157+ link_results,
158+)
159+
160+config = get_configuration()
161+
162+class LexbuilderHelpersTemplateTagTests(TestCase):
163+
164+ def test_link_results(self):
165+ base_uri = config.get("web", "build_results_uri")
166+ project_name = "foobar"
167+ build_date = "201202"
168+ build_id = "0"
169+ expected_link = "%s/%s/%s/%s" % (
170+ base_uri, project_name, build_date, build_id)
171+ self.assertEqual(
172+ link_results(project_name, "%s-%s" % (build_date, build_id)),
173+ expected_link)
174+
175+
176
177=== modified file 'setup.py'
178--- setup.py 2011-11-11 01:13:02 +0000
179+++ setup.py 2012-04-19 19:48:22 +0000
180@@ -16,8 +16,8 @@
181 ],
182 entry_points = {
183 'console_scripts': [
184- '../scripts/cron/build-active-projects = offspring.master:build_active_projects',
185- '../scripts/cron/process-pending-build-orders = offspring.master:process_pending_build_orders',
186+ '../scripts/cron/build-active-projects = offspring.master.utils:build_active_projects',
187+ '../scripts/cron/process-pending-build-orders = offspring.master.utils:process_pending_build_orders',
188 '../scripts/cron/publish-pending-releases = offspring.master.scripts.publish_pending_releases:run',
189 '../scripts/cron/sync-launchpad-project-milestones = offspring.master.scripts.sync_launchpad_project_milestones:run',
190 '../scripts/offspring-builder-config = offspring.config:print_builder_config',

Subscribers

People subscribed via source and target branches