1023.1.2
by Aaron Bentley
First python version of gotestwin.py |
1 |
#!/usr/bin/env python
|
2 |
from argparse import ArgumentParser |
|
3 |
from json import dump |
|
4 |
import os |
|
5 |
from os.path import ( |
|
6 |
basename, |
|
7 |
dirname, |
|
8 |
join, |
|
9 |
)
|
|
10 |
import subprocess |
|
1489.1.14
by Curtis Hovey
Added test for gotestwin. |
11 |
import sys |
12 |
||
13 |
||
14 |
SCRIPTS = dirname(__file__) |
|
15 |
||
16 |
||
17 |
def main(argv=None): |
|
1023.1.2
by Aaron Bentley
First python version of gotestwin.py |
18 |
parser = ArgumentParser() |
1023.1.3
by Aaron Bentley
Add docs. |
19 |
parser.add_argument('host', help='The machine to test on.') |
1489.1.19
by Curtis Hovey
Revisions per review. |
20 |
parser.add_argument('revision_or_tarfile', |
1489.1.14
by Curtis Hovey
Added test for gotestwin. |
21 |
help='The revision-build or tarfile path to test.') |
1023.1.3
by Aaron Bentley
Add docs. |
22 |
parser.add_argument('package', nargs='?', default='github.com/juju/juju', |
23 |
help='The package to test.') |
|
1489.1.14
by Curtis Hovey
Added test for gotestwin. |
24 |
args = parser.parse_args(argv) |
1023.1.2
by Aaron Bentley
First python version of gotestwin.py |
25 |
|
1489.1.19
by Curtis Hovey
Revisions per review. |
26 |
if args.revision_or_tarfile.endswith('tar.gz'): |
27 |
downloaded = args.revision_or_tarfile |
|
1489.1.12
by Curtis Hovey
Upload local tarfile. |
28 |
else: |
1489.1.19
by Curtis Hovey
Revisions per review. |
29 |
revision = args.revision_or_tarfile |
1489.1.14
by Curtis Hovey
Added test for gotestwin. |
30 |
juju_ci_path = join(SCRIPTS, 'jujuci.py') |
1489.1.12
by Curtis Hovey
Upload local tarfile. |
31 |
downloaded = subprocess.check_output([ |
1489.1.19
by Curtis Hovey
Revisions per review. |
32 |
juju_ci_path, 'get', '-b', revision, 'build-revision', |
1489.1.12
by Curtis Hovey
Upload local tarfile. |
33 |
'*.tar.gz', './']) |
1489.1.16
by Curtis Hovey
Added rule to use local tarfiel. |
34 |
subprocess.check_call([ |
1489.1.19
by Curtis Hovey
Revisions per review. |
35 |
juju_ci_path, 'get-build-vars', '--summary', revision]) |
1023.1.4
by Aaron Bentley
Retrieve just the tarball. |
36 |
(tarfile,) = [basename(l) for l in downloaded.splitlines()] |
1023.1.2
by Aaron Bentley
First python version of gotestwin.py |
37 |
|
38 |
with open('temp-config.yaml', 'w') as temp_file: |
|
39 |
dump({ |
|
40 |
'install': {'ci': [ |
|
41 |
tarfile, |
|
1489.1.14
by Curtis Hovey
Added test for gotestwin. |
42 |
join(SCRIPTS, 'gotesttarfile.py'), |
43 |
join(SCRIPTS, 'jujucharm.py'), |
|
44 |
join(SCRIPTS, 'utility.py'), |
|
1023.1.2
by Aaron Bentley
First python version of gotestwin.py |
45 |
]},
|
1027.2.4
by seman.said at canonical
Updated unit test in test_schedule_hetero_control. |
46 |
'command': [ |
1023.1.2
by Aaron Bentley
First python version of gotestwin.py |
47 |
'python', 'ci/gotesttarfile.py', '-v', '-g', 'go.exe', '-p', |
48 |
args.package, '--remove', 'ci/{}'.format(tarfile) |
|
1027.2.4
by seman.said at canonical
Updated unit test in test_schedule_hetero_control. |
49 |
]},
|
1031.1.4
by Curtis Hovey
Hush lint. |
50 |
temp_file) |
1023.1.2
by Aaron Bentley
First python version of gotestwin.py |
51 |
juju_home = os.environ.get('JUJU_HOME', |
1489.1.14
by Curtis Hovey
Added test for gotestwin. |
52 |
join(dirname(SCRIPTS), 'cloud-city')) |
1023.1.2
by Aaron Bentley
First python version of gotestwin.py |
53 |
subprocess.check_call([ |
54 |
'workspace-run', '-v', '-i', join(juju_home, 'staging-juju-rsa'), |
|
55 |
'temp-config.yaml', 'Administrator@{}'.format(args.host) |
|
56 |
])
|
|
57 |
||
1023.1.3
by Aaron Bentley
Add docs. |
58 |
|
1023.1.2
by Aaron Bentley
First python version of gotestwin.py |
59 |
if __name__ == '__main__': |
1489.1.14
by Curtis Hovey
Added test for gotestwin. |
60 |
main(sys.argv[1:]) |