1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/usr/bin/env python
from argparse import ArgumentParser
from jujuci import (
add_credential_args,
get_credentials,
)
from utility import (
find_candidates,
get_auth_token,
)
from jenkins import Jenkins
from industrial_test import (
FULL,
suites,
)
def parse_args(argv=None):
parser = ArgumentParser()
parser.add_argument(
'root_dir', help='Directory containing releases and candidates dir')
parser.add_argument('--suite', help='Test suite to run', default=[],
choices=suites.keys(), action='append')
parser.add_argument('jobs', nargs='*', metavar='job',
help='Jobs to schedule builds for.')
add_credential_args(parser)
result = parser.parse_args(argv)
if result.jobs == []:
result.jobs = None
credentials = get_credentials(result)
return result, credentials
def build_job(credentials, root, job_name, candidates, suite):
parameters = {'suite': ','.join(suite), 'attempts': '10'}
jenkins = Jenkins('http://localhost:8080', credentials.user,
credentials.password)
for candidate in candidates:
call_parameters = {'new_juju_dir': candidate}
call_parameters.update(parameters)
token = get_auth_token(root, job_name)
jenkins.build_job(job_name, call_parameters, token=token)
def main():
args, credentials = parse_args()
suite = args.suite
if suite == []:
suite = [FULL]
candidates = list(find_candidates(args.root_dir))
jobs = args.jobs
if jobs is None:
jobs = ['industrial-test', 'industrial-test-aws',
'industrial-test-joyent']
for job in jobs:
build_job(credentials, args.root_dir, job, candidates, suite)
if __name__ == '__main__':
main()
|