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

« back to all changes in this revision

Viewing changes to test-win-client

  • Committer: Aaron Bentley
  • Date: 2014-02-24 17:18:29 UTC
  • mto: This revision was merged to the branch mainline in revision 252.
  • Revision ID: aaron.bentley@canonical.com-20140224171829-sz644yhoygu7m9dm
Use tags to identify and shut down instances.

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', 'fakejuju.py', 'jujupy.py',
36
 
        'jujuconfig.py', 'remote.py', 'substrate.py', 'utility.py',
37
 
        'get_ami.py', 'chaos.py', 'timeout.py', 'jujucharm.py',
38
 
        'winazurearm.py',
39
 
        ]]
40
 
    ci.extend([install_file, 'run-file'])
41
 
    with open('foo.yaml', 'w') as config:
42
 
        yaml.dump({
43
 
            'install': {'ci': ci},
44
 
            'command': ['ci/run-file', install_file],
45
 
            }, config)
46
 
    subprocess.check_call(['workspace-run', '-v', 'foo.yaml', host, '-i',
47
 
                           private_key])
48
 
 
49
 
 
50
 
def main():
51
 
    parser = ArgumentParser()
52
 
    parser.add_argument('address',
53
 
                        help='The IP or DNS address the windows test machine.')
54
 
    parser.add_argument('revision_build',
55
 
                        help='Revision-build to test.')
56
 
    parser.add_argument(
57
 
        '--juju-home', default=os.environ.get('JUJU_HOME'),
58
 
        help='The location of cloud-city and staging-juju-rsa.')
59
 
    script_dir = os.path.dirname(__file__)
60
 
    win_test(script_dir=script_dir, **parser.parse_args().__dict__)
61
 
 
62
 
 
63
 
if __name__ == '__main__':
64
 
    main()
 
1
#!/bin/bash
 
2
set -eux
 
3
INSTANCE_ID="i-514c2871"
 
4
 
 
5
echo Starting instance $INSTANCE_ID
 
6
euca-start-instances $INSTANCE_ID
 
7
if [ $? -ne 0 ]; then
 
8
    exit 1
 
9
fi
 
10
 
 
11
set +x
 
12
instance_ip=''
 
13
echo -n Waiting for IP address
 
14
while [ -z "$instance_ip" ]; do
 
15
    sleep 1
 
16
        instance_ip=$(euca-describe-instances $INSTANCE_ID |
 
17
            sed '/^INSTANCE/!d' |
 
18
            cut -f 17)
 
19
    echo -n .
 
20
done
 
21
echo
 
22
echo Instance has ip $instance_ip
 
23
sleep 30
 
24
 
 
25
echo -n Waiting for SSH
 
26
while ! netcat $instance_ip 22 -w 1 -q 0 </dev/null >/dev/null; do
 
27
    sleep 1
 
28
    echo -n .
 
29
done
 
30
echo
 
31
 
 
32
set -x
 
33
scp -i $JUJU_HOME/staging-juju-rsa \
 
34
    -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" \
 
35
    $SCRIPTS/deploy_stack.py $SCRIPTS/jujupy.py $SCRIPTS/jujuconfig.py \
 
36
    Administrator@$instance_ip:/cygdrive/c/Users/Administrator/ci/
 
37
if [ $? -ne 0 ]; then
 
38
    exit 1
 
39
fi
 
40
ssh -i $JUJU_HOME/staging-juju-rsa \
 
41
    -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" \
 
42
    Administrator@$instance_ip \
 
43
    'juju destroy-environment --force -y test-win-client || juju destroy-environment -y -e test-win-client'
 
44
ssh -i $JUJU_HOME/staging-juju-rsa \
 
45
    -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" \
 
46
    Administrator@$instance_ip \
 
47
    '/cygdrive/c/python27/python \\Users\\Administrator\\ci\\deploy_stack.py' \
 
48
     test-win-client
 
49
EXIT_STATUS=$?
 
50
ssh -i $JUJU_HOME/staging-juju-rsa \
 
51
    -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" \
 
52
    Administrator@$instance_ip \
 
53
    'juju destroy-environment --force -y test-win-client || juju destroy-environment -y -e test-win-client'
 
54
set -e
 
55
set +x
 
56
euca-stop-instances $INSTANCE_ID
 
57
exit $EXIT_STATUS