~andrewjbeach/juju-ci-tools/make-local-patcher

« back to all changes in this revision

Viewing changes to schedule_reliability_tests.py

  • Committer: Aaron Bentley
  • Date: 2015-01-19 15:32:33 UTC
  • mto: This revision was merged to the branch mainline in revision 804.
  • Revision ID: aaron.bentley@canonical.com-20150119153233-jjcvikwiw1dx2lak
Print error on missing environment.

Show diffs side-by-side

added added

removed removed

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