initial integration test setup

Integration tests are only run on circle. They checkout the weave
project, and use test helpers from there.

There are just a few basic tests for now, to confirm it works.
This commit is contained in:
Paul Bellamy
2015-06-22 11:17:12 +01:00
parent f8be412dbb
commit ff9771f112
10 changed files with 254 additions and 0 deletions

109
bin/setup-circleci-secrets Executable file
View File

@@ -0,0 +1,109 @@
#!/bin/bash
set -eu
# openssl enc -in do-setup-circleci-secrets.orig -out setup-circleci-secrets.orig -e -aes256 -pass stdin
# openssl base64 < setup-circleci-secrets.orig
openssl base64 -d << EOF \
| openssl enc \
-out bin/do-setup-circleci-secrets \
-d -aes256 -pass pass:$1
U2FsdGVkX193YHZJXNzxU9GqigQaXWrA0AKd+BIjRcx7bmmKn/zSgOv+FfApRRjn
KGBd2ulZw9CwsftX0HWHzVdtpgqbJUW+FEma8eNldau4/f+T+yWTVpCNQXGc3DvB
cWYhmkoTfGWmI2v/0/Bv2TYkw7MAfjCocdluFAv7sSvYnSgIjoYxD4XXkTjLWy1P
KUMUBPSRgQlyY01fTHmh+mvY/pLAF+Cfe+vvBNbCUVj2IfplWbN/K3ewco8UHJQI
9KZO36dvevExXfIhCa0FS1A9cxjTRl+wX6pi9d6XCbfmJ727CPOBz1Cla2+Yr3Pr
yXuTb/oIgKZ2tbmFrABRmui69NLqfi7AwkWM7W8Xs3oxrY09TRtyuN6gc3X+vlhu
2ylNFgVQEA4KfWDewfl8zILYwzO5gMpEpkduFMjSTn3v170s7IYjUtNyq9FFA/GK
kfh/LCPYIXyk6qoRLNEOFw2DkA04D3dG6Qm0np2TacBdEBchYQhZB1wqKNCOj6rZ
ROBgBvn5DwiE51WOGdnekWF1chbFReVXcW8Nl4XWZTQ8HoRRx7F0JgV+PRMqvxpn
Qp5Iv/TTvYwQUToM0XK7GdQObDvC6vnuCQXLl+iBOXwsEp1jzf/3Zb45vp+L5Qwi
p2HaT+cvW1SkSwktO34mnGVMRRb8/TqtEKCVCLlNXNiZPIDyKr0HLOs3sdXT844f
K8h9qmStr9bRpa7QBMX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yZMdtVWloF4TOVODNNxA+zAE9fUgrI=
EOF
exec sh bin/do-setup-circleci-secrets

View File

@@ -2,6 +2,7 @@ general:
branches:
ignore:
- gh-pages
- /pull\/.*/
machine:
services:
@@ -10,6 +11,7 @@ machine:
GOPATH: /home/ubuntu:$GOPATH
SRCDIR: /home/ubuntu/src/github.com/weaveworks/scope
PATH: $PATH:$HOME/.local/bin
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
SCOPE_UI_BUILD: $HOME/docker/scope_ui_build.tar
dependencies:
@@ -24,6 +26,8 @@ dependencies:
mkdir -p $(dirname "$SCOPE_UI_BUILD");
mv scope_ui_build.tar $(dirname "$SCOPE_UI_BUILD");
fi
- curl https://sdk.cloud.google.com | bash
- bin/setup-circleci-secrets "$SECRET_PASSWORD"
post:
- go version
- go clean -i net
@@ -40,7 +44,12 @@ test:
- cd $SRCDIR; make
- cd $SRCDIR; ./bin/test -slow
- cd $SRCDIR/experimental; make
- cd $SRCDIR/integration; ./gce.sh setup
- cd $SRCDIR/integration; . ./gce.sh hosts; ./setup.sh
- cd $SRCDIR/integration; . ./gce.sh hosts; ./run_all.sh:
timeout: 300
post:
- cd $SRCDIR/integration; ./gce.sh destroy
- goveralls -repotoken $COVERALLS_REPO_TOKEN -coverprofile=$SRCDIR/profile.cov -service=circleci || true
- cd $SRCDIR; cp coverage.html $CIRCLE_ARTIFACTS
- cd $SRCDIR; cp scope.tar $CIRCLE_ARTIFACTS

3
integration/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
insecure_private_key
.vagrant
.ssh_known_hosts

10
integration/100_launch_test.sh Executable file
View File

@@ -0,0 +1,10 @@
#! /bin/bash
. ./config.sh
start_suite "Launch scope and check it boots"
scope_on $HOST1 launch
assert_raises "curl $HOST1:4040"
end_suite

View File

@@ -0,0 +1,14 @@
#! /bin/bash
. ./config.sh
start_suite "Launch 2 scopes and check they cluster"
weave_on $HOST2 launch
container_id=$(start_container $HOST2)
scope_on $HOST1 launch
scope_on $HOST2 launch
assert_raises "curl $HOST1:4040/api/topology/containers | grep '$container_id'"
end_suite

52
integration/README.md Normal file
View File

@@ -0,0 +1,52 @@
This directory contains integration tests for scope.
## Requirements
You need two VMs with docker >=1.3.1 installed and listening on TCP
port 2375 (see below). You also need to be able to ssh to these VMs,
preferably without having to input anything.
The `Vagrantfile` in this directory constructs two such VMs. To meet
the aforementioned ssh requirement you may want to
cp ~/.vagrant.d/insecure_private_key .
## Running tests
./setup.sh
Downloads a copy of weave (if not already downloaded) and calls it's
setup.sh script. Then, it uploads the scope images from where the
Makefile puts them (`/var/tmp`) to the two docker hosts, and copies
the scope script over.
Then you can use, e.g.,
./100_launch_test.sh
to run an individual test, or
./run_all.sh
to run everything named `*_test.sh`.
## Using other VMs
By default the tests assume the Vagrant VMs are used.
To use other VMs, set the environment variable <var>HOSTS</var> to the
space-separated list of IP addresses of the docker hosts, and set the
environment variable <var>SSH</var> to a command that will log into
either (which may just be `ssh`).
## Making docker available over TCP
To make docker listen to a TCP socket, you will usually need to either
run it manually with an option like `-H tcp://0.0.0.0:2375`; or, for
apt-get installed docker (Ubuntu and Debian), add the line
```
DOCKER_OPTS="--host unix:///var/run/docker.sock --host tcp://0.0.0.0:2375"
```
to the file `/etc/default/docker`, then restart docker.

25
integration/config.sh Normal file
View File

@@ -0,0 +1,25 @@
# NB only to be sourced
set -e
# these ought to match what is in Vagrantfile
# exported to override weave config.sh
export SSH_DIR="$PWD"
export HOSTS
WEAVE_REPO="github.com/weaveworks/weave"
WEAVE_ROOT="${GOPATH%%:*}/src/$WEAVE_REPO"
if [ ! -d "$WEAVE_ROOT" ] ; then
mkdir -p "$(dirname "$WEAVE_ROOT")"
git clone --depth 1 -b master https://$WEAVE_REPO.git "$WEAVE_ROOT"
go get $WEAVE_REPO/...
fi
. "$WEAVE_ROOT/test/config.sh"
scope_on() {
host=$1
shift 1
[ -z "$DEBUG" ] || greyly echo "Scope on $host: $@" >&2
run_on $host "DOCKER_HOST=tcp://$host:$DOCKER_PORT" scope "$@"
}

8
integration/gce.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
set -e
. ./config.sh
export PROJECT=scope-integration-tests
. "$WEAVE_ROOT/test/gce.sh" "$@"

7
integration/run_all.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
set -e
. ./config.sh
NO_SCHEDULER=1 "$WEAVE_ROOT/test/run_all.sh" "$@"

17
integration/setup.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
set -e
. ./config.sh
echo Copying scope images and scripts to hosts
for HOST in $HOSTS; do
docker_on $HOST load -i ../scope.tar
upload_executable $HOST ../scope
done
echo Installing weave
for HOST in $HOSTS; do
run_on $HOST "sudo curl -L git.io/weave -o /usr/local/bin/weave"
run_on $HOST "sudo chmod a+x /usr/local/bin/weave"
done