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

« back to all changes in this revision

Viewing changes to gotestwin.bash

  • Committer: Curtis Hovey
  • Date: 2015-06-16 13:54:07 UTC
  • mto: This revision was merged to the branch mainline in revision 991.
  • Revision ID: curtis@canonical.com-20150616135407-xzq45ixl2xqqooli
Always collect logs from quickstart and deployer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
11
 
import sys
12
 
 
13
 
 
14
 
SCRIPTS = dirname(__file__)
15
 
 
16
 
 
17
 
def main(argv=None):
18
 
    parser = ArgumentParser()
19
 
    parser.add_argument('host', help='The machine to test on.')
20
 
    parser.add_argument('revision_or_tarfile',
21
 
                        help='The revision-build or tarfile path to test.')
22
 
    parser.add_argument('package', nargs='?', default='github.com/juju/juju',
23
 
                        help='The package to test.')
24
 
    args = parser.parse_args(argv)
25
 
 
26
 
    if args.revision_or_tarfile.endswith('tar.gz'):
27
 
        downloaded = args.revision_or_tarfile
28
 
    else:
29
 
        revision = args.revision_or_tarfile
30
 
        juju_ci_path = join(SCRIPTS, 'jujuci.py')
31
 
        downloaded = subprocess.check_output([
32
 
            juju_ci_path, 'get', '-b', revision, 'build-revision',
33
 
            '*.tar.gz', './'])
34
 
        subprocess.check_call([
35
 
            juju_ci_path, 'get-build-vars', '--summary', revision])
36
 
    (tarfile,) = [basename(l) for l in downloaded.splitlines()]
37
 
 
38
 
    with open('temp-config.yaml', 'w') as temp_file:
39
 
        dump({
40
 
            'install': {'ci': [
41
 
                tarfile,
42
 
                join(SCRIPTS, 'gotesttarfile.py'),
43
 
                join(SCRIPTS, 'jujucharm.py'),
44
 
                join(SCRIPTS, 'utility.py'),
45
 
                ]},
46
 
            'command': [
47
 
                'python', 'ci/gotesttarfile.py', '-v', '-g', 'go.exe', '-p',
48
 
                args.package, '--remove', 'ci/{}'.format(tarfile)
49
 
                ]},
50
 
             temp_file)
51
 
    juju_home = os.environ.get('JUJU_HOME',
52
 
                               join(dirname(SCRIPTS), 'cloud-city'))
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
 
 
58
 
 
59
 
if __name__ == '__main__':
60
 
    main(sys.argv[1:])
 
1
#!/bin/bash
 
2
set -eu
 
3
SCRIPTS=$(readlink -f $(dirname $0))
 
4
JUJU_HOME=${JUJU_HOME:-$(dirname $SCRIPTS)/cloud-city}
 
5
 
 
6
HOST="$1"
 
7
REVISION="$2"
 
8
PACKAGE=${3:-github.com/juju/juju}
 
9
 
 
10
CYG_CI_DIR="/cygdrive/c/Users/Administrator/ci"
 
11
CYG_PYTHON_CMD="/cygdrive/c/python27/python"
 
12
CI_DIR='\\Users\\Administrator\\ci'
 
13
GO_CMD='\\go\\bin\\go.exe'
 
14
SSH_OPTIONS="-i $JUJU_HOME/staging-juju-rsa \
 
15
    -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
 
16
 
 
17
set -x
 
18
DOWNLOADED=$($SCRIPTS/jujuci.py get -b $REVISION build-revision '*' ./)
 
19
TARFILE=$(basename $(echo "$DOWNLOADED" | grep -F tar.gz))
 
20
$SCRIPTS/jujuci.py get-build-vars --summary --env $HOST $REVISION
 
21
 
 
22
 
 
23
scp $SSH_OPTIONS ./$TARFILE $SCRIPTS/gotesttarfile.py \
 
24
    Administrator@$HOST:$CYG_CI_DIR/
 
25
if [ $? -ne 0 ]; then
 
26
    exit 1
 
27
fi
 
28
 
 
29
ssh $SSH_OPTIONS Administrator@$HOST \
 
30
    $CYG_PYTHON_CMD $CI_DIR'\\gotesttarfile.py' -v -g $GO_CMD -p $PACKAGE \
 
31
    --remove $CI_DIR'\\'$TARFILE
 
32
EXIT_STATUS=$?
 
33
 
 
34
exit $EXIT_STATUS