672
by Aaron Bentley
Switch to unix line endings. |
1 |
#!/usr/bin/env python
|
2 |
from __future__ import print_function |
|
3 |
||
4 |
from argparse import ArgumentParser |
|
1027.2.1
by seman.said at canonical
Get candidate version from the buildvars.json file |
5 |
import json |
672
by Aaron Bentley
Switch to unix line endings. |
6 |
import os |
1074.4.1
by Curtis Hovey
Do not schedule releases for testing and devel juju clients. |
7 |
import re |
672
by Aaron Bentley
Switch to unix line endings. |
8 |
|
9 |
from jenkins import Jenkins |
|
870.1.2
by Aaron Bentley
Use authenticated access for schedule_hetero_control. |
10 |
from jujuci import ( |
11 |
add_credential_args, |
|
12 |
get_credentials, |
|
13 |
)
|
|
777.1.2
by Aaron Bentley
Use find_candidates in schedule-hetero.control |
14 |
from utility import ( |
15 |
find_candidates, |
|
16 |
get_candidates_path, |
|
17 |
)
|
|
672
by Aaron Bentley
Switch to unix line endings. |
18 |
|
19 |
||
870.1.2
by Aaron Bentley
Use authenticated access for schedule_hetero_control. |
20 |
def get_args(argv=None): |
672
by Aaron Bentley
Switch to unix line endings. |
21 |
parser = ArgumentParser() |
676
by Aaron Bentley
Restore root_dir. |
22 |
parser.add_argument( |
23 |
'root_dir', help='Directory containing releases and candidates dir') |
|
1029.1.1
by seman.said at canonical
Added --all option to schedule all candidates for client-server testing. |
24 |
parser.add_argument( |
25 |
'--all', action='store_true', default=False, |
|
26 |
help='Schedule all candidates for client-server testing.') |
|
870.1.2
by Aaron Bentley
Use authenticated access for schedule_hetero_control. |
27 |
add_credential_args(parser) |
28 |
args = parser.parse_args(argv) |
|
29 |
return args, get_credentials(args) |
|
672
by Aaron Bentley
Switch to unix line endings. |
30 |
|
31 |
||
32 |
def get_releases(root): |
|
33 |
release_path = os.path.join(root, 'old-juju') |
|
1074.4.1
by Curtis Hovey
Do not schedule releases for testing and devel juju clients. |
34 |
released_pattern = re.compile('^\d+\.\d+\.\d+[^~]*$') |
672
by Aaron Bentley
Switch to unix line endings. |
35 |
for entry in os.listdir(release_path): |
36 |
if not os.path.isdir(os.path.join(release_path, entry)): |
|
37 |
continue
|
|
1074.4.1
by Curtis Hovey
Do not schedule releases for testing and devel juju clients. |
38 |
if released_pattern.match(entry): |
39 |
yield entry |
|
672
by Aaron Bentley
Switch to unix line endings. |
40 |
|
41 |
||
1082.2.1
by seman.said at canonical
Added scheduling client-server tests for all OSes. |
42 |
def get_candidate_info(candidate_path): |
43 |
""" Return candidate version and revision build number. """
|
|
1027.2.1
by seman.said at canonical
Get candidate version from the buildvars.json file |
44 |
with open(os.path.join(candidate_path, 'buildvars.json')) as fp: |
1082.2.1
by seman.said at canonical
Added scheduling client-server tests for all OSes. |
45 |
build_vars = json.load(fp) |
46 |
return build_vars['version'], build_vars['revision_build'] |
|
1027.2.1
by seman.said at canonical
Get candidate version from the buildvars.json file |
47 |
|
48 |
||
1029.1.1
by seman.said at canonical
Added --all option to schedule all candidates for client-server testing. |
49 |
def calculate_jobs(root, schedule_all=False): |
672
by Aaron Bentley
Switch to unix line endings. |
50 |
releases = list(get_releases(root)) |
777.1.2
by Aaron Bentley
Use find_candidates in schedule-hetero.control |
51 |
candidates_path = get_candidates_path(root) |
1029.1.1
by seman.said at canonical
Added --all option to schedule all candidates for client-server testing. |
52 |
for candidate_path in find_candidates(root, schedule_all): |
777.1.2
by Aaron Bentley
Use find_candidates in schedule-hetero.control |
53 |
parent, candidate = os.path.split(candidate_path) |
1207
by Curtis Hovey
skip any client-server that starts with 1.26. |
54 |
if candidate.startswith('1.26'): |
1168.1.1
by Curtis Hovey
Do not test 1.26 for client-server compatability because it is really 2.x |
55 |
# 1.26 was renamed to 2.0 because it is not compatible with 1.x
|
56 |
continue
|
|
777.1.2
by Aaron Bentley
Use find_candidates in schedule-hetero.control |
57 |
if parent != candidates_path: |
58 |
raise ValueError('Wrong path') |
|
1082.2.1
by seman.said at canonical
Added scheduling client-server tests for all OSes. |
59 |
candidate_version, revision_build = get_candidate_info(candidate_path) |
672
by Aaron Bentley
Switch to unix line endings. |
60 |
for release in releases: |
1171.1.1
by seman.said at canonical
Added a comment. |
61 |
# Releases with the same major number must be compatible.
|
1169.2.1
by seman.said at canonical
Do not test version 2.0 against 1.0 or vice versa. |
62 |
if release[:2] != candidate[:2]: |
63 |
continue
|
|
1168.1.1
by Curtis Hovey
Do not test 1.26 for client-server compatability because it is really 2.x |
64 |
for client_os in ('ubuntu', 'osx', 'windows'): |
1082.2.1
by seman.said at canonical
Added scheduling client-server tests for all OSes. |
65 |
yield { |
66 |
'old_version': release, # Client |
|
67 |
'candidate': candidate_version, # Server |
|
68 |
'new_to_old': 'true', |
|
69 |
'candidate_path': candidate, |
|
70 |
'client_os': client_os, |
|
71 |
'revision_build': revision_build, |
|
72 |
}
|
|
73 |
yield { |
|
74 |
'old_version': release, # Server |
|
75 |
'candidate': candidate_version, # Client |
|
76 |
'new_to_old': 'false', |
|
77 |
'candidate_path': candidate, |
|
78 |
'client_os': client_os, |
|
79 |
'revision_build': revision_build, |
|
80 |
}
|
|
1066.1.1
by seman.said at canonical
Added client_os label during scheduling the client-server test. |
81 |
|
82 |
||
870.1.2
by Aaron Bentley
Use authenticated access for schedule_hetero_control. |
83 |
def build_jobs(credentials, root, jobs): |
1549.1.1
by Curtis Hovey
Removed get_toekn; all jobs require authentication anyway. |
84 |
jenkins = Jenkins('http://juju-ci.vapour.ws:8080', *credentials) |
1091.4.1
by James Tunnicliffe
Merged upstream |
85 |
os_str = {"ubuntu": "", "osx": "-osx", "windows": "-windows"} |
672
by Aaron Bentley
Switch to unix line endings. |
86 |
for job in jobs: |
1091.4.1
by James Tunnicliffe
Merged upstream |
87 |
jenkins.build_job( |
1549.1.1
by Curtis Hovey
Removed get_toekn; all jobs require authentication anyway. |
88 |
'compatibility-control{}'.format(os_str[job['client_os']]), job) |
672
by Aaron Bentley
Switch to unix line endings. |
89 |
|
90 |
||
91 |
def main(): |
|
870.1.2
by Aaron Bentley
Use authenticated access for schedule_hetero_control. |
92 |
args, credentials = get_args() |
1029.1.1
by seman.said at canonical
Added --all option to schedule all candidates for client-server testing. |
93 |
build_jobs( |
94 |
credentials, args.root_dir, calculate_jobs(args.root_dir, args.all)) |
|
672
by Aaron Bentley
Switch to unix line endings. |
95 |
|
96 |
||
97 |
if __name__ == '__main__': |
|
98 |
main() |