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
=== modified file 'schedule_hetero_control.py'
--- schedule_hetero_control.py 2015-07-16 15:57:13 +0000
+++ schedule_hetero_control.py 2015-07-20 18:05:04 +0000
@@ -21,6 +21,9 @@
21 parser = ArgumentParser()21 parser = ArgumentParser()
22 parser.add_argument(22 parser.add_argument(
23 'root_dir', help='Directory containing releases and candidates dir')23 'root_dir', help='Directory containing releases and candidates dir')
24 parser.add_argument(
25 '--all', action='store_true', default=False,
26 help='Schedule all candidates for client-server testing.')
24 add_credential_args(parser)27 add_credential_args(parser)
25 args = parser.parse_args(argv)28 args = parser.parse_args(argv)
26 return args, get_credentials(args)29 return args, get_credentials(args)
@@ -39,10 +42,10 @@
39 return json.load(fp)['version']42 return json.load(fp)['version']
4043
4144
42def calculate_jobs(root):45def calculate_jobs(root, schedule_all=False):
43 releases = list(get_releases(root))46 releases = list(get_releases(root))
44 candidates_path = get_candidates_path(root)47 candidates_path = get_candidates_path(root)
45 for candidate_path in find_candidates(root):48 for candidate_path in find_candidates(root, schedule_all):
46 parent, candidate = os.path.split(candidate_path)49 parent, candidate = os.path.split(candidate_path)
47 if parent != candidates_path:50 if parent != candidates_path:
48 raise ValueError('Wrong path')51 raise ValueError('Wrong path')
@@ -51,12 +54,14 @@
51 yield {54 yield {
52 'old_version': release,55 'old_version': release,
53 'candidate': candidate_version,56 'candidate': candidate_version,
54 'new_to_old': 'true'57 'new_to_old': 'true',
58 'candidate_path': candidate
55 }59 }
56 yield {60 yield {
57 'old_version': release,61 'old_version': release,
58 'candidate': candidate_version,62 'candidate': candidate_version,
59 'new_to_old': 'false'63 'new_to_old': 'false',
64 'candidate_path': candidate
60 }65 }
6166
6267
@@ -69,7 +74,8 @@
6974
70def main():75def main():
71 args, credentials = get_args()76 args, credentials = get_args()
72 build_jobs(credentials, args.root_dir, calculate_jobs(args.root_dir))77 build_jobs(
78 credentials, args.root_dir, calculate_jobs(args.root_dir, args.all))
7379
7480
75if __name__ == '__main__':81if __name__ == '__main__':
7682
=== modified file 'test_schedule_hetero_control.py'
--- test_schedule_hetero_control.py 2015-07-16 17:34:29 +0000
+++ test_schedule_hetero_control.py 2015-07-20 18:05:04 +0000
@@ -2,8 +2,10 @@
22
3__metaclass__ = type3__metaclass__ = type
44
5from datetime import timedelta
5import json6import json
6import os7import os
8from time import time
7from unittest import TestCase9from unittest import TestCase
810
9from mock import patch11from mock import patch
@@ -41,32 +43,71 @@
41 jenkins_mock.assert_called_once_with(43 jenkins_mock.assert_called_once_with(
42 'http://localhost:8080', 'jrandom', 'password1')44 'http://localhost:8080', 'jrandom', 'password1')
4345
46
47class TestGetCandidateVersion(TestCase):
44 def test_get_candidate_version(self):48 def test_get_candidate_version(self):
45 with temp_dir() as dir_path:49 with temp_dir() as dir_path:
46 self.make_build_var_file(dir_path)50 make_build_var_file(dir_path, version='1.24.3')
47 version = get_candidate_version(dir_path)51 version = get_candidate_version(dir_path)
48 self.assertEqual(version, '1.24.3')52 self.assertEqual(version, '1.24.3')
4953
54
55class CalculateJobs(TestCase):
50 def test_calculate_jobs(self):56 def test_calculate_jobs(self):
51 with temp_dir() as root:57 with temp_dir() as root:
52 release_path = os.path.join(root, 'old-juju', '1.20.11')58 release_path = os.path.join(root, 'old-juju', '1.20.11')
53 os.makedirs(release_path)59 os.makedirs(release_path)
54 candidate_path = os.path.join(root, 'candidate', '1.22')60 candidate_path = os.path.join(root, 'candidate', '1.24')
55 os.makedirs(candidate_path)61 os.makedirs(candidate_path)
56 jobs = []62 make_build_var_file(candidate_path, version='1.24.3')
57 self.make_build_var_file(candidate_path)63 jobs = list(calculate_jobs(root))
58 for job in calculate_jobs(root):
59 jobs.append(job)
60 expected = [{'new_to_old': 'true',64 expected = [{'new_to_old': 'true',
61 'old_version': '1.20.11',65 'old_version': '1.20.11',
62 'candidate': '1.24.3'},66 'candidate': '1.24.3',
67 'candidate_path': '1.24'},
63 {'new_to_old': 'false',68 {'new_to_old': 'false',
64 'old_version': '1.20.11',69 'old_version': '1.20.11',
65 'candidate': '1.24.3'}]70 'candidate': '1.24.3',
71 'candidate_path': '1.24'}]
66 self.assertItemsEqual(jobs, expected)72 self.assertItemsEqual(jobs, expected)
6773
68 def make_build_var_file(self, dir_path):74 def test_calculate_jobs_schedule_all(self):
69 build_vars = {"version": "1.24.3", "revision_build": "2870"}75 with temp_dir() as root:
70 file_path = os.path.join(dir_path, 'buildvars.json')76 release_path = os.path.join(root, 'old-juju', '1.20.11')
71 with open(file_path, 'w') as json_file:77 os.makedirs(release_path)
72 json.dump(build_vars, json_file)78 candidate_path = os.path.join(root, 'candidate', '1.24')
79 os.makedirs(candidate_path)
80 make_build_var_file(candidate_path, '1.24.3')
81 candidate_path_2 = os.path.join(root, 'candidate', '1.23')
82 os.makedirs(candidate_path_2)
83 buildvars_path = make_build_var_file(candidate_path_2, '1.23.3')
84 a_week_ago = time() - timedelta(days=7, seconds=1).total_seconds()
85 os.utime(buildvars_path, (time(), a_week_ago))
86 jobs = list(calculate_jobs(root, schedule_all=False))
87 jobs_schedule_all = list(calculate_jobs(root, schedule_all=True))
88 expected = [{'new_to_old': 'true',
89 'old_version': '1.20.11',
90 'candidate': '1.23.3',
91 'candidate_path': '1.23'},
92 {'new_to_old': 'false',
93 'old_version': '1.20.11',
94 'candidate': '1.23.3',
95 'candidate_path': '1.23'},
96 {'new_to_old': 'true',
97 'old_version': '1.20.11',
98 'candidate': '1.24.3',
99 'candidate_path': '1.24'},
100 {'new_to_old': 'false',
101 'old_version': '1.20.11',
102 'candidate': '1.24.3',
103 'candidate_path': '1.24'}]
104 self.assertItemsEqual(jobs, expected[2:])
105 self.assertItemsEqual(jobs_schedule_all, expected)
106
107
108def make_build_var_file(dir_path, version):
109 build_vars = {"version": version, "revision_build": "2870"}
110 file_path = os.path.join(dir_path, 'buildvars.json')
111 with open(file_path, 'w') as json_file:
112 json.dump(build_vars, json_file)
113 return file_path
73114
=== modified file 'test_utility.py'
--- test_utility.py 2015-07-16 18:23:21 +0000
+++ test_utility.py 2015-07-20 18:05:04 +0000
@@ -120,24 +120,36 @@
120120
121 def test_find_candidates_old_buildvars(self):121 def test_find_candidates_old_buildvars(self):
122 with temp_dir() as root:122 with temp_dir() as root:
123 candidates_path = get_candidates_path(root)123 _, buildvars_path = self.make_candidates_dir(root, 'master')
124 os.mkdir(candidates_path)
125 master_path = os.path.join(candidates_path, 'master')
126 os.mkdir(master_path)
127 buildvars_path = os.path.join(master_path, 'buildvars.json')
128 open(buildvars_path, 'w')
129 a_week_ago = time() - timedelta(days=7, seconds=1).total_seconds()124 a_week_ago = time() - timedelta(days=7, seconds=1).total_seconds()
130 os.utime(buildvars_path, (time(), a_week_ago))125 os.utime(buildvars_path, (time(), a_week_ago))
131 self.assertEqual(list(find_candidates(root)), [])126 self.assertEqual(list(find_candidates(root)), [])
132127
133 def test_find_candidates_artifacts(self):128 def test_find_candidates_artifacts(self):
134 with temp_dir() as root:129 with temp_dir() as root:
135 candidates_path = get_candidates_path(root)130 self.make_candidates_dir(root, 'master-artifacts')
131 self.assertEqual(list(find_candidates(root)), [])
132
133 def test_find_candidates_find_all(self):
134 with temp_dir() as root:
135 master_path, buildvars_path = self.make_candidates_dir(
136 root, '1.23')
137 master_path_2, _ = self.make_candidates_dir(root, '1.24')
138 a_week_ago = time() - timedelta(days=7, seconds=1).total_seconds()
139 os.utime(buildvars_path, (time(), a_week_ago))
140 self.assertItemsEqual(list(find_candidates(root)), [master_path_2])
141 self.assertItemsEqual(list(find_candidates(root, find_all=True)),
142 [master_path, master_path_2])
143
144 def make_candidates_dir(self, root, master_name):
145 candidates_path = get_candidates_path(root)
146 if not os.path.isdir(candidates_path):
136 os.mkdir(candidates_path)147 os.mkdir(candidates_path)
137 master_path = os.path.join(candidates_path, 'master-artifacts')148 master_path = os.path.join(candidates_path, master_name)
138 os.mkdir(master_path)149 os.mkdir(master_path)
139 open(os.path.join(master_path, 'buildvars.json'), 'w')150 buildvars_path = os.path.join(master_path, 'buildvars.json')
140 self.assertEqual(list(find_candidates(root)), [])151 open(buildvars_path, 'w')
152 return master_path, buildvars_path
141153
142154
143class TestWaitForPort(TestCase):155class TestWaitForPort(TestCase):
144156
=== modified file 'utility.py'
--- utility.py 2015-07-17 21:43:36 +0000
+++ utility.py 2015-07-20 18:05:04 +0000
@@ -286,7 +286,7 @@
286 return os.path.join(root_dir, 'candidate')286 return os.path.join(root_dir, 'candidate')
287287
288288
289def find_candidates(root_dir):289def find_candidates(root_dir, find_all=False):
290 candidates_path = get_candidates_path(root_dir)290 candidates_path = get_candidates_path(root_dir)
291 a_week_ago = time() - timedelta(days=7).total_seconds()291 a_week_ago = time() - timedelta(days=7).total_seconds()
292 for candidate_dir in os.listdir(candidates_path):292 for candidate_dir in os.listdir(candidates_path):
@@ -300,7 +300,7 @@
300 if e.errno in (errno.ENOENT, errno.ENOTDIR):300 if e.errno in (errno.ENOENT, errno.ENOTDIR):
301 continue301 continue
302 raise302 raise
303 if stat.st_mtime < a_week_ago:303 if not find_all and stat.st_mtime < a_week_ago:
304 continue304 continue
305 yield candidate_path305 yield candidate_path
306306

Subscribers

People subscribed via source and target branches