757.2.1
by Aaron Bentley
Start implementing building industrial tests. |
1 |
#!/usr/bin/env python
|
2 |
from argparse import ArgumentParser |
|
870.1.1
by Aaron Bentley
Use authenticated access for schedule_reliability_tests. |
3 |
|
4 |
from jujuci import ( |
|
5 |
add_credential_args, |
|
6 |
get_credentials, |
|
7 |
)
|
|
777.1.1
by Aaron Bentley
Move find_candidates, get under test. |
8 |
from utility import ( |
1071.1.4
by Aaron Bentley
Use find_branch_latest, and limit to 3. |
9 |
find_latest_branch_candidates, |
777.1.1
by Aaron Bentley
Move find_candidates, get under test. |
10 |
get_auth_token, |
757.2.1
by Aaron Bentley
Start implementing building industrial tests. |
11 |
)
|
12 |
||
13 |
from jenkins import Jenkins |
|
14 |
||
769.2.1
by Aaron Bentley
Allow suite to be specified. |
15 |
from industrial_test import ( |
16 |
FULL, |
|
17 |
suites, |
|
18 |
)
|
|
19 |
||
20 |
||
21 |
def parse_args(argv=None): |
|
757.2.1
by Aaron Bentley
Start implementing building industrial tests. |
22 |
parser = ArgumentParser() |
23 |
parser.add_argument( |
|
24 |
'root_dir', help='Directory containing releases and candidates dir') |
|
872.1.1
by Aaron Bentley
Accept multiple --suite options. |
25 |
parser.add_argument('--suite', help='Test suite to run', default=[], |
26 |
choices=suites.keys(), action='append') |
|
769.2.2
by Aaron Bentley
Allow specifying jobs for schedule_reliability_tests. |
27 |
parser.add_argument('jobs', nargs='*', metavar='job', |
28 |
help='Jobs to schedule builds for.') |
|
870.1.1
by Aaron Bentley
Use authenticated access for schedule_reliability_tests. |
29 |
add_credential_args(parser) |
769.2.2
by Aaron Bentley
Allow specifying jobs for schedule_reliability_tests. |
30 |
result = parser.parse_args(argv) |
31 |
if result.jobs == []: |
|
32 |
result.jobs = None |
|
870.1.1
by Aaron Bentley
Use authenticated access for schedule_reliability_tests. |
33 |
credentials = get_credentials(result) |
34 |
return result, credentials |
|
35 |
||
36 |
||
37 |
def build_job(credentials, root, job_name, candidates, suite): |
|
872.1.1
by Aaron Bentley
Accept multiple --suite options. |
38 |
parameters = {'suite': ','.join(suite), 'attempts': '10'} |
870.1.1
by Aaron Bentley
Use authenticated access for schedule_reliability_tests. |
39 |
jenkins = Jenkins('http://localhost:8080', credentials.user, |
40 |
credentials.password) |
|
1302.1.1
by Aaron Bentley
Include revision_build in industrial-test job params. |
41 |
for candidate, revision_build in candidates: |
42 |
call_parameters = { |
|
43 |
'revision_build': '{:d}'.format(revision_build), |
|
44 |
}
|
|
769.2.1
by Aaron Bentley
Allow suite to be specified. |
45 |
call_parameters.update(parameters) |
757.2.3
by Aaron Bentley
Fix job names. |
46 |
token = get_auth_token(root, job_name) |
769.2.1
by Aaron Bentley
Allow suite to be specified. |
47 |
jenkins.build_job(job_name, call_parameters, token=token) |
757.2.1
by Aaron Bentley
Start implementing building industrial tests. |
48 |
|
49 |
||
1071.1.4
by Aaron Bentley
Use find_branch_latest, and limit to 3. |
50 |
def main(argv=None): |
51 |
args, credentials = parse_args(argv) |
|
872.1.1
by Aaron Bentley
Accept multiple --suite options. |
52 |
suite = args.suite |
53 |
if suite == []: |
|
54 |
suite = [FULL] |
|
1071.1.8
by Aaron Bentley
Remove redundant list(). |
55 |
candidates = find_latest_branch_candidates(args.root_dir)[:3] |
769.2.2
by Aaron Bentley
Allow specifying jobs for schedule_reliability_tests. |
56 |
jobs = args.jobs |
57 |
if jobs is None: |
|
58 |
jobs = ['industrial-test', 'industrial-test-aws', |
|
59 |
'industrial-test-joyent'] |
|
60 |
for job in jobs: |
|
872.1.1
by Aaron Bentley
Accept multiple --suite options. |
61 |
build_job(credentials, args.root_dir, job, candidates, suite) |
757.2.1
by Aaron Bentley
Start implementing building industrial tests. |
62 |
|
63 |
||
64 |
if __name__ == '__main__': |
|
65 |
main() |