Merge lp:~sseman/juju-ci-tools/schedule-all into lp:juju-ci-tools

Proposed by Seman
Status: Merged
Merged at revision: 1037
Proposed branch: lp:~sseman/juju-ci-tools/schedule-all
Merge into: lp:juju-ci-tools
Diff against target: 226 lines (+90/-31)
4 files modified
schedule_hetero_control.py (+11/-5)
test_schedule_hetero_control.py (+54/-13)
test_utility.py (+23/-11)
utility.py (+2/-2)
To merge this branch: bzr merge lp:~sseman/juju-ci-tools/schedule-all
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+265300@code.launchpad.net

Description of the change

This branch updates schedule_hetero_control adding "--all" option to schedule all candidates for client-server testing. This will allow us to retest releases in candidates directory with the correct version information.

Since 'candidate' parameter contains version info rather than branch, the compatibility-control job may not able to find the path to the candidate directory. I updated schedule_hetero_control so that it returns 'candidate_path' parameter. This parameter will contain the path to the candidate directory

When this branch gets approved, I will add "candidate_path" parameter to the http://juju-ci.vapour.ws/job/compatibility-control/configure job. I will also update the shell script.
from:
  new_juju=$(find $HOME/candidate/$candidate -name juju)
to:
  new_juju=$(find $HOME/candidate/$candidate_path -name juju)

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'schedule_hetero_control.py'
2--- schedule_hetero_control.py 2015-07-16 15:57:13 +0000
3+++ schedule_hetero_control.py 2015-07-20 18:05:04 +0000
4@@ -21,6 +21,9 @@
5 parser = ArgumentParser()
6 parser.add_argument(
7 'root_dir', help='Directory containing releases and candidates dir')
8+ parser.add_argument(
9+ '--all', action='store_true', default=False,
10+ help='Schedule all candidates for client-server testing.')
11 add_credential_args(parser)
12 args = parser.parse_args(argv)
13 return args, get_credentials(args)
14@@ -39,10 +42,10 @@
15 return json.load(fp)['version']
16
17
18-def calculate_jobs(root):
19+def calculate_jobs(root, schedule_all=False):
20 releases = list(get_releases(root))
21 candidates_path = get_candidates_path(root)
22- for candidate_path in find_candidates(root):
23+ for candidate_path in find_candidates(root, schedule_all):
24 parent, candidate = os.path.split(candidate_path)
25 if parent != candidates_path:
26 raise ValueError('Wrong path')
27@@ -51,12 +54,14 @@
28 yield {
29 'old_version': release,
30 'candidate': candidate_version,
31- 'new_to_old': 'true'
32+ 'new_to_old': 'true',
33+ 'candidate_path': candidate
34 }
35 yield {
36 'old_version': release,
37 'candidate': candidate_version,
38- 'new_to_old': 'false'
39+ 'new_to_old': 'false',
40+ 'candidate_path': candidate
41 }
42
43
44@@ -69,7 +74,8 @@
45
46 def main():
47 args, credentials = get_args()
48- build_jobs(credentials, args.root_dir, calculate_jobs(args.root_dir))
49+ build_jobs(
50+ credentials, args.root_dir, calculate_jobs(args.root_dir, args.all))
51
52
53 if __name__ == '__main__':
54
55=== modified file 'test_schedule_hetero_control.py'
56--- test_schedule_hetero_control.py 2015-07-16 17:34:29 +0000
57+++ test_schedule_hetero_control.py 2015-07-20 18:05:04 +0000
58@@ -2,8 +2,10 @@
59
60 __metaclass__ = type
61
62+from datetime import timedelta
63 import json
64 import os
65+from time import time
66 from unittest import TestCase
67
68 from mock import patch
69@@ -41,32 +43,71 @@
70 jenkins_mock.assert_called_once_with(
71 'http://localhost:8080', 'jrandom', 'password1')
72
73+
74+class TestGetCandidateVersion(TestCase):
75 def test_get_candidate_version(self):
76 with temp_dir() as dir_path:
77- self.make_build_var_file(dir_path)
78+ make_build_var_file(dir_path, version='1.24.3')
79 version = get_candidate_version(dir_path)
80 self.assertEqual(version, '1.24.3')
81
82+
83+class CalculateJobs(TestCase):
84 def test_calculate_jobs(self):
85 with temp_dir() as root:
86 release_path = os.path.join(root, 'old-juju', '1.20.11')
87 os.makedirs(release_path)
88- candidate_path = os.path.join(root, 'candidate', '1.22')
89+ candidate_path = os.path.join(root, 'candidate', '1.24')
90 os.makedirs(candidate_path)
91- jobs = []
92- self.make_build_var_file(candidate_path)
93- for job in calculate_jobs(root):
94- jobs.append(job)
95+ make_build_var_file(candidate_path, version='1.24.3')
96+ jobs = list(calculate_jobs(root))
97 expected = [{'new_to_old': 'true',
98 'old_version': '1.20.11',
99- 'candidate': '1.24.3'},
100+ 'candidate': '1.24.3',
101+ 'candidate_path': '1.24'},
102 {'new_to_old': 'false',
103 'old_version': '1.20.11',
104- 'candidate': '1.24.3'}]
105+ 'candidate': '1.24.3',
106+ 'candidate_path': '1.24'}]
107 self.assertItemsEqual(jobs, expected)
108
109- def make_build_var_file(self, dir_path):
110- build_vars = {"version": "1.24.3", "revision_build": "2870"}
111- file_path = os.path.join(dir_path, 'buildvars.json')
112- with open(file_path, 'w') as json_file:
113- json.dump(build_vars, json_file)
114+ def test_calculate_jobs_schedule_all(self):
115+ with temp_dir() as root:
116+ release_path = os.path.join(root, 'old-juju', '1.20.11')
117+ os.makedirs(release_path)
118+ candidate_path = os.path.join(root, 'candidate', '1.24')
119+ os.makedirs(candidate_path)
120+ make_build_var_file(candidate_path, '1.24.3')
121+ candidate_path_2 = os.path.join(root, 'candidate', '1.23')
122+ os.makedirs(candidate_path_2)
123+ buildvars_path = make_build_var_file(candidate_path_2, '1.23.3')
124+ a_week_ago = time() - timedelta(days=7, seconds=1).total_seconds()
125+ os.utime(buildvars_path, (time(), a_week_ago))
126+ jobs = list(calculate_jobs(root, schedule_all=False))
127+ jobs_schedule_all = list(calculate_jobs(root, schedule_all=True))
128+ expected = [{'new_to_old': 'true',
129+ 'old_version': '1.20.11',
130+ 'candidate': '1.23.3',
131+ 'candidate_path': '1.23'},
132+ {'new_to_old': 'false',
133+ 'old_version': '1.20.11',
134+ 'candidate': '1.23.3',
135+ 'candidate_path': '1.23'},
136+ {'new_to_old': 'true',
137+ 'old_version': '1.20.11',
138+ 'candidate': '1.24.3',
139+ 'candidate_path': '1.24'},
140+ {'new_to_old': 'false',
141+ 'old_version': '1.20.11',
142+ 'candidate': '1.24.3',
143+ 'candidate_path': '1.24'}]
144+ self.assertItemsEqual(jobs, expected[2:])
145+ self.assertItemsEqual(jobs_schedule_all, expected)
146+
147+
148+def make_build_var_file(dir_path, version):
149+ build_vars = {"version": version, "revision_build": "2870"}
150+ file_path = os.path.join(dir_path, 'buildvars.json')
151+ with open(file_path, 'w') as json_file:
152+ json.dump(build_vars, json_file)
153+ return file_path
154
155=== modified file 'test_utility.py'
156--- test_utility.py 2015-07-16 18:23:21 +0000
157+++ test_utility.py 2015-07-20 18:05:04 +0000
158@@ -120,24 +120,36 @@
159
160 def test_find_candidates_old_buildvars(self):
161 with temp_dir() as root:
162- candidates_path = get_candidates_path(root)
163- os.mkdir(candidates_path)
164- master_path = os.path.join(candidates_path, 'master')
165- os.mkdir(master_path)
166- buildvars_path = os.path.join(master_path, 'buildvars.json')
167- open(buildvars_path, 'w')
168+ _, buildvars_path = self.make_candidates_dir(root, 'master')
169 a_week_ago = time() - timedelta(days=7, seconds=1).total_seconds()
170 os.utime(buildvars_path, (time(), a_week_ago))
171 self.assertEqual(list(find_candidates(root)), [])
172
173 def test_find_candidates_artifacts(self):
174 with temp_dir() as root:
175- candidates_path = get_candidates_path(root)
176+ self.make_candidates_dir(root, 'master-artifacts')
177+ self.assertEqual(list(find_candidates(root)), [])
178+
179+ def test_find_candidates_find_all(self):
180+ with temp_dir() as root:
181+ master_path, buildvars_path = self.make_candidates_dir(
182+ root, '1.23')
183+ master_path_2, _ = self.make_candidates_dir(root, '1.24')
184+ a_week_ago = time() - timedelta(days=7, seconds=1).total_seconds()
185+ os.utime(buildvars_path, (time(), a_week_ago))
186+ self.assertItemsEqual(list(find_candidates(root)), [master_path_2])
187+ self.assertItemsEqual(list(find_candidates(root, find_all=True)),
188+ [master_path, master_path_2])
189+
190+ def make_candidates_dir(self, root, master_name):
191+ candidates_path = get_candidates_path(root)
192+ if not os.path.isdir(candidates_path):
193 os.mkdir(candidates_path)
194- master_path = os.path.join(candidates_path, 'master-artifacts')
195- os.mkdir(master_path)
196- open(os.path.join(master_path, 'buildvars.json'), 'w')
197- self.assertEqual(list(find_candidates(root)), [])
198+ master_path = os.path.join(candidates_path, master_name)
199+ os.mkdir(master_path)
200+ buildvars_path = os.path.join(master_path, 'buildvars.json')
201+ open(buildvars_path, 'w')
202+ return master_path, buildvars_path
203
204
205 class TestWaitForPort(TestCase):
206
207=== modified file 'utility.py'
208--- utility.py 2015-07-17 21:43:36 +0000
209+++ utility.py 2015-07-20 18:05:04 +0000
210@@ -286,7 +286,7 @@
211 return os.path.join(root_dir, 'candidate')
212
213
214-def find_candidates(root_dir):
215+def find_candidates(root_dir, find_all=False):
216 candidates_path = get_candidates_path(root_dir)
217 a_week_ago = time() - timedelta(days=7).total_seconds()
218 for candidate_dir in os.listdir(candidates_path):
219@@ -300,7 +300,7 @@
220 if e.errno in (errno.ENOENT, errno.ENOTDIR):
221 continue
222 raise
223- if stat.st_mtime < a_week_ago:
224+ if not find_all and stat.st_mtime < a_week_ago:
225 continue
226 yield candidate_path
227

Subscribers

People subscribed via source and target branches