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

« back to all changes in this revision

Viewing changes to test-win-client

  • Committer: John George
  • Date: 2015-01-14 22:03:47 UTC
  • mto: This revision was merged to the branch mainline in revision 798.
  • Revision ID: john.george@canonical.com-20150114220347-e8q5wezs1qg9a00u
Added support for setting the juju path, series and agent_url.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
from argparse import ArgumentParser
3
 
import os
4
 
import re
5
 
import subprocess
6
 
from textwrap import dedent
7
 
from utility import s3_cmd
8
 
import yaml
9
 
 
10
 
 
11
 
def win_test(script_dir, address, juju_home, revision_build):
12
 
    host = 'Administrator@{}'.format(address)
13
 
    private_key = os.path.join(juju_home, 'staging-juju-rsa')
14
 
    revision_build_url = (
15
 
        's3://juju-qa-data/juju-ci/products/version-{}'.format(revision_build))
16
 
    win_client_url = '{}/build-win-client/'.format(revision_build_url)
17
 
    output = s3_cmd(['ls', '-r', win_client_url])
18
 
    urls = sorted(l.split()[3] for l in output.splitlines())
19
 
    installer = [u for u in urls if re.search('juju-setup-.*\.exe', u)][-1]
20
 
    s3_cmd(['sync', installer, '.'])
21
 
    install_file = installer.split('/')[-1]
22
 
    with open('run-file', 'w') as run_file:
23
 
        run_file.write(dedent("""
24
 
            ci/$1 /verysilent
25
 
            juju version
26
 
            juju destroy-environment --force -y win-client-deploy
27
 
            mkdir logs
28
 
            python ci\\\\deploy_job.py parallel-win-client \
29
 
                'c:\\Program Files (x86)\\Juju\\juju.exe' \
30
 
                logs win-client-deploy --series trusty \
31
 
                --agent-stream revision-build-{revision_build}
32
 
            """.format(revision_build=revision_build)))
33
 
 
34
 
    ci = [os.path.join(script_dir, f) for f in [
35
 
        'deploy_stack.py', 'deploy_job.py', 'jujupy.py', 'jujuconfig.py',
36
 
        'remote.py', 'substrate.py', 'utility.py', 'get_ami.py', 'chaos.py',
37
 
        'timeout.py',
38
 
        ]]
39
 
    ci.extend([install_file, 'run-file'])
40
 
    with open('foo.yaml', 'w') as config:
41
 
        yaml.dump({
42
 
            'install': {'ci': ci},
43
 
            'command': ['ci/run-file', install_file],
44
 
            }, config)
45
 
    subprocess.check_call(['workspace-run', '-v', 'foo.yaml', host, '-i',
46
 
                           private_key])
47
 
 
48
 
 
49
 
def main():
50
 
    parser = ArgumentParser()
51
 
    parser.add_argument('address',
52
 
                        help='The IP or DNS address the windows test machine.')
53
 
    parser.add_argument('revision_build',
54
 
                        help='Revision-build to test.')
55
 
    parser.add_argument(
56
 
        '--juju-home', default=os.environ.get('JUJU_HOME'),
57
 
        help='The location of cloud-city and staging-juju-rsa.')
58
 
    script_dir = os.path.dirname(__file__)
59
 
    win_test(script_dir=script_dir, **parser.parse_args().__dict__)
60
 
 
61
 
 
62
 
if __name__ == '__main__':
63
 
    main()
 
1
#!/bin/bash
 
2
set -eux
 
3
 
 
4
 
 
5
usage() {
 
6
    echo "usage: $0 ADDRESS"
 
7
    echo "  ADDRESS: The IP or DNS address the windows test machine."
 
8
    echo "  --juju-home: The location of cloud-city and staging-juju-rsa."
 
9
    exit 1
 
10
}
 
11
 
 
12
INSTALL_JUJU="false"
 
13
while [[ "${1-}" != "" && $1 =~ ^-.*  ]]; do
 
14
    case $1 in
 
15
        --juju-home)
 
16
            shift
 
17
            JUJU_HOME=$(cd $1; pwd)
 
18
            ;;
 
19
        --install-juju)
 
20
            INSTALL_JUJU="true"
 
21
            ;;
 
22
        --help)
 
23
            usage
 
24
            ;;
 
25
    esac
 
26
    shift
 
27
done
 
28
 
 
29
 
 
30
test $# -eq 1 || usage
 
31
 
 
32
HOST="$1"
 
33
: ${SCRIPTS=$(readlink -f $(dirname $0))}
 
34
export PATH="$SCRIPTS:$PATH"
 
35
 
 
36
SSH_OPTIONS="-i $JUJU_HOME/staging-juju-rsa \
 
37
    -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
 
38
 
 
39
set -x
 
40
if [[ $INSTALL_JUJU == "true" ]]; then
 
41
    installer=$(
 
42
        $SCRIPTS/jujuci.py get build-win-client 'juju-setup-*.exe' ./)
 
43
    echo "Downloaded $installer"
 
44
    scp $SSH_OPTIONS $installer \
 
45
        Administrator@$HOST:/cygdrive/c/Users/Administrator/ci
 
46
    ssh $SSH_OPTIONS Administrator@$HOST \
 
47
        /cygdrive/c/Users/Administrator/ci/$installer /verysilent
 
48
    ssh $SSH_OPTIONS Administrator@$HOST juju version
 
49
fi
 
50
 
 
51
scp $SSH_OPTIONS \
 
52
    $SCRIPTS/deploy_stack.py $SCRIPTS/jujupy.py $SCRIPTS/jujuconfig.py \
 
53
    $SCRIPTS/substrate.py $SCRIPTS/utility.py \
 
54
    Administrator@$HOST:/cygdrive/c/Users/Administrator/ci/
 
55
if [ $? -ne 0 ]; then
 
56
    exit 1
 
57
fi
 
58
set +e
 
59
ssh $SSH_OPTIONS Administrator@$HOST \
 
60
    'juju destroy-environment --force -y test-win-client'
 
61
ssh $SSH_OPTIONS Administrator@$HOST \
 
62
    '/cygdrive/c/python27/python \\Users\\Administrator\\ci\\deploy_stack.py' \
 
63
     test-win-client
 
64
EXIT_STATUS=$?
 
65
ssh $SSH_OPTIONS Administrator@$HOST \
 
66
    'juju destroy-environment --force -y test-win-client'
 
67
set -e
 
68
set +x
 
69
exit $EXIT_STATUS