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

« back to all changes in this revision

Viewing changes to run-uitests.bash

  • Committer: Martin Packman
  • Date: 2015-12-16 03:59:38 UTC
  • mto: This revision was merged to the branch mainline in revision 1200.
  • Revision ID: martin.packman@canonical.com-20151216035938-881wbry7ezh8he5m
Add missing template test file

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash
2
 
# Run the uitests with the juju created from the release tar file
3
 
# or from the approximate source of the tar file.
4
 
 
5
 
# About SUITE
6
 
# We require "TestJujuCore" SUITE to verify Juju's interaction with the GUI.
7
 
# The "TestCharm" SUITE verifies charm plugin deps with juju.
8
 
# "not TestStorefront" Theoretically work if we accept the consequences
9
 
# of building both Juju and the charm plugin with undocumented deps.
10
 
# "TestStorefront" fails, maybe because of phantom. firefox reports
11
 
# Xvfb did not start, but xfvb works for the win client job.
12
 
# SUITE cannot be an empty string if non-essential suites will fail.
13
 
# see http://pytest.org/latest/example/markers.html#using-k-expr-to-select-tests-based-on-their-name
14
 
# for the syntax supported by $SUITE.
15
 
 
16
 
set -eu
17
 
export USER=jenkins
18
 
export SCRIPTS=$HOME/juju-ci-tools
19
 
export RELEASE_TOOLS=$HOME/juju-release-tools
20
 
export JUJU_UITEST=$HOME/eco-repos/src/github.com/CanonicalLtd/juju-uitest
21
 
export CLOUD_CITY=$HOME/cloud-city
22
 
export S3_CONFIG=$CLOUD_CITY/juju-qa.s3cfg
23
 
source $CLOUD_CITY/staging-charm-store.rc
24
 
set -x
25
 
 
26
 
export PATH=/usr/lib/go-1.6/bin:$PATH
27
 
 
28
 
REVISION_BUILD=${1:-$revision_build}
29
 
SUITE=${2:-TestJujuCore}
30
 
JOB_NAME=${3:-juju-with-uitest}
31
 
WORKSPACE=${4:-$WORKSPACE}
32
 
 
33
 
# Setup a workspace and TMPDIR to keep all test files in one place.
34
 
if [[ -z $WORKSPACE || $WORKSPACE == './' || $WORKSPACE == './' ]]; then
35
 
    echo "Set a sane WORKSPACE: [$WORKSPACE] is not safe."
36
 
    exit 1
37
 
fi
38
 
WORKSPACE=$(readlink -f $WORKSPACE)
39
 
$SCRIPTS/jujuci.py -v setup-workspace $WORKSPACE
40
 
export TMPDIR="$WORKSPACE/tmp"
41
 
mkdir $TMPDIR
42
 
 
43
 
# uitest only supports master and near tip branches.
44
 
# This is a design flaw because 1.25 will live a long time and
45
 
# we want to catch API breakages with the GUI.
46
 
source $($SCRIPTS/s3ci.py get --config $S3_CONFIG $REVISION_BUILD build-revision buildvars.bash)
47
 
if [[ $VERSION =~ ^1\..*$ ]]; then
48
 
    echo "$VERSION is not supported uitests"
49
 
    exit 0
50
 
fi
51
 
 
52
 
# Print a summary for the jenkins job description.
53
 
$SCRIPTS/s3ci.py get-summary $REVISION_BUILD $JOB_NAME
54
 
 
55
 
# Get the pristine tarfile and unpack it to build a tainted testing juju.
56
 
JUJU_ARCHIVE=$($SCRIPTS/s3ci.py get --config $S3_CONFIG $REVISION_BUILD build-revision juju-core_.*.tar.gz)
57
 
tar -xf $JUJU_ARCHIVE
58
 
JUJU_DIR=$(basename $JUJU_ARCHIVE .tar.gz)
59
 
export GOPATH=$WORKSPACE/$JUJU_DIR
60
 
JUJU_PACKAGE=$GOPATH/src/github.com/juju/juju
61
 
CHARM_PACKAGE=$GOPATH/src/github.com/juju/charm
62
 
# Add the charm package to the tree.
63
 
go get github.com/juju/charm/...
64
 
 
65
 
# If tree must be tampered with, then let it be us who do it to ensure
66
 
# we understand what is not being tested.
67
 
CSCLIENT="$GOPATH/src/gopkg.in/juju/charmrepo.v2-unstable/csclient/csclient.go"
68
 
API_URL=$(echo $STORE_URL | sed -e "s,//,//api.,")
69
 
SERVER_PATTERN="s,https://api.jujucharms.com,$API_URL,"
70
 
sed -i -e "$SERVER_PATTERN" $CSCLIENT
71
 
for PACKAGE in $JUJU_PACKAGE $CHARM_PACKAGE; do
72
 
    cd $PACKAGE
73
 
    go install ./...
74
 
done
75
 
cd $WORKSPACE
76
 
ls $GOPATH/bin
77
 
 
78
 
# Get the releases Juju GUI.
79
 
GUI_URL=$(sstream-query http://streams.canonical.com/juju/gui/streams/v1/index.json --output-format="%(item_url)s" | head -1)
80
 
GUI_ARCHIVE=$(basename $GUI_URL)
81
 
wget $GUI_URL
82
 
 
83
 
# Create credentials for the TestJujuCore tests.
84
 
# We really want a helper script based on deploy_stack.py to create
85
 
# an arbitrary temp env from cloud-city.
86
 
export JUJU_DATA=$CLOUD_CITY/jes-homes/$JOB_NAME
87
 
export JUJU_HOME=$JUJU_DATA
88
 
test -d $JUJU_DATA && rm -r $JUJU_DATA
89
 
mkdir -p $JUJU_DATA
90
 
cat << EOT > $JUJU_DATA/credentials.yaml
91
 
credentials:
92
 
  google:
93
 
    default-region: us-central1
94
 
    default-credential: juju-qa
95
 
    juju-qa:
96
 
      auth-type: jsonfile
97
 
      file: $CLOUD_CITY/gce-4f8322be6f89.json
98
 
EOT
99
 
 
100
 
# Setup juju-uitest from the local copy.
101
 
cp -r $JUJU_UITEST $WORKSPACE/juju-uitest
102
 
cd $WORKSPACE/juju-uitest
103
 
make
104
 
 
105
 
 
106
 
# Do not reveal credentials.
107
 
echo "devenv/bin/uitest --driver phantom \
108
 
    -c google \
109
 
    --gui-archive $WORKSPACE/$GUI_ARCHIVE \
110
 
    --gopath $GOPATH \
111
 
    --credentials <SECRET> \
112
 
    --admin <SECRET> \
113
 
    --url $STORE_URL" \
114
 
    "$SUITE"
115
 
set +x
116
 
devenv/bin/uitest --driver phantom \
117
 
    -c google \
118
 
    --gui-archive $WORKSPACE/$GUI_ARCHIVE \
119
 
    --gopath $GOPATH \
120
 
    --credentials $STORE_CREDENTIALS \
121
 
    --admin $STORE_ADMIN \
122
 
    --url $STORE_URL \
123
 
    "$SUITE"