mirror of
https://github.com/weaveworks/scope.git
synced 2026-02-14 18:09:59 +00:00
Make integration test check API responses contain expected containers.
Also - Add test for clustering without weave. - Update test template for docker 1.8 - Prefetch images - Stop all containers when test finishes. - Add small sleep after weave launch, and supply all the hosts to ensure IPAM works correctly.
This commit is contained in:
1
integration/.gitignore
vendored
1
integration/.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
insecure_private_key
|
||||
.vagrant
|
||||
.ssh_known_hosts
|
||||
weave
|
||||
|
||||
@@ -4,7 +4,13 @@
|
||||
|
||||
start_suite "Launch scope and check it boots"
|
||||
|
||||
weave_on $HOST1 launch
|
||||
scope_on $HOST1 launch
|
||||
assert_raises "curl $HOST1:4040"
|
||||
|
||||
end_suite
|
||||
sleep 5
|
||||
|
||||
has_container $HOST1 weave 1
|
||||
has_container $HOST1 weaveproxy 1
|
||||
has_container $HOST1 weavescope 1
|
||||
|
||||
scope_end_suite
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
|
||||
start_suite "Launch scope (without weave installed) and check it boots"
|
||||
|
||||
assert_raises "run_on $HOST1 \
|
||||
PATH=/usr/local/scope/bin:/usr/sbin:/usr/bin:/sbin:/bin \
|
||||
DOCKER_HOST=tcp://$HOST1:$DOCKER_PORT \
|
||||
scope launch"
|
||||
scope_on $HOST1 launch
|
||||
|
||||
assert_raises "curl $HOST1:4040"
|
||||
sleep 5
|
||||
|
||||
end_suite
|
||||
has_container $HOST1 weave 0
|
||||
has_container $HOST1 weaveproxy 0
|
||||
has_container $HOST1 weavescope 1
|
||||
|
||||
scope_end_suite
|
||||
|
||||
@@ -13,4 +13,4 @@ assert_raises "docker_on $HOST1 logs weavescope 2>&1 | grep 'app exiting'"
|
||||
assert_raises "docker_on $HOST1 logs weavescope 2>&1 | grep 'probe exiting'"
|
||||
assert_raises "docker_on $HOST1 inspect --format='{{.State.Running}}' weavescope" "false"
|
||||
|
||||
end_suite
|
||||
scope_end_suite
|
||||
|
||||
@@ -2,24 +2,30 @@
|
||||
|
||||
. ./config.sh
|
||||
|
||||
start_suite "Launch 2 scopes and check they cluster"
|
||||
start_suite "Launch 2 scopes and check they cluster automatically"
|
||||
|
||||
weave_on $HOST2 launch
|
||||
weave_on $HOST2 launch-dns
|
||||
docker_on $HOST2 run -dit --name db1 peterbourgon/tns-db
|
||||
container_id=$(docker_on $HOST2 run -dit --name app1 --link db1:db1 peterbourgon/tns-app)
|
||||
weave_on $HOST1 launch $HOST1 $HOST2
|
||||
weave_on $HOST2 launch $HOST1 $HOST2
|
||||
|
||||
scope_on $HOST1 launch $HOST2
|
||||
scope_on $HOST2 launch $HOST1
|
||||
sleep 10 # let weave settle
|
||||
|
||||
SUCCESS=
|
||||
for i in {1..10}; do
|
||||
if (curl -s $HOST1:4040/api/topology/containers | grep "$container_id" >/dev/null); then
|
||||
SUCCESS=1
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
assert "echo $SUCCESS" "1"
|
||||
scope_on $HOST1 launch
|
||||
scope_on $HOST2 launch
|
||||
|
||||
end_suite
|
||||
docker_on $HOST1 run -dit --name db1 peterbourgon/tns-db
|
||||
docker_on $HOST2 run -dit --name db2 peterbourgon/tns-db
|
||||
|
||||
sleep 30
|
||||
|
||||
check() {
|
||||
has_container $1 weave 2
|
||||
has_container $1 weaveproxy 2
|
||||
has_container $1 weavescope 2
|
||||
has_container $1 db1 1
|
||||
has_container $1 db2 1
|
||||
}
|
||||
|
||||
check $HOST1
|
||||
check $HOST2
|
||||
|
||||
scope_end_suite
|
||||
|
||||
26
integration/205_clustering_sans_weave_2_test.sh
Executable file
26
integration/205_clustering_sans_weave_2_test.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#! /bin/bash
|
||||
|
||||
. ./config.sh
|
||||
|
||||
start_suite "Launch 2 scopes and check they cluster (without weave)"
|
||||
|
||||
scope_on $HOST1 launch $HOST1 $HOST2
|
||||
scope_on $HOST2 launch $HOST1 $HOST2
|
||||
|
||||
docker_on $HOST1 run -dit --name db1 peterbourgon/tns-db
|
||||
docker_on $HOST2 run -dit --name db2 peterbourgon/tns-db
|
||||
|
||||
sleep 30
|
||||
|
||||
check() {
|
||||
has_container $1 weave 0
|
||||
has_container $1 weaveproxy 0
|
||||
has_container $1 weavescope 2
|
||||
has_container $1 db1 1
|
||||
has_container $1 db2 1
|
||||
}
|
||||
|
||||
check $HOST1
|
||||
check $HOST2
|
||||
|
||||
scope_end_suite
|
||||
@@ -10,21 +10,38 @@ export HOSTS
|
||||
: ${WEAVE_REPO:=github.com/weaveworks/weave}
|
||||
: ${WEAVE_ROOT:="$(go list -e -f {{.Dir}} $WEAVE_REPO)"}
|
||||
|
||||
WEAVE="./weave"
|
||||
SCOPE="../scope"
|
||||
RUNNER="$WEAVE_ROOT/testing/runner/runner"
|
||||
[ -x "$RUNNER" ] || (echo "Could not find weave test runner at $RUNNER." >&2 ; exit 1)
|
||||
|
||||
. "$WEAVE_ROOT/test/config.sh"
|
||||
|
||||
scope_on() {
|
||||
host=$1
|
||||
local host=$1
|
||||
shift 1
|
||||
[ -z "$DEBUG" ] || greyly echo "Scope on $host: $@" >&2
|
||||
run_on $host DOCKER_HOST=tcp://$host:$DOCKER_PORT scope "$@"
|
||||
DOCKER_HOST=tcp://$host:$DOCKER_PORT $SCOPE "$@"
|
||||
}
|
||||
|
||||
weave_on() {
|
||||
host=$1
|
||||
local host=$1
|
||||
shift 1
|
||||
[ -z "$DEBUG" ] || greyly echo "Weave on $host: $@" >&2
|
||||
run_on $host DOCKER_HOST=tcp://$host:$DOCKER_PORT weave "$@"
|
||||
DOCKER_HOST=tcp://$host:$DOCKER_PORT $WEAVE "$@"
|
||||
}
|
||||
|
||||
# this checks we have a weavescope container
|
||||
has_container() {
|
||||
local host=$1
|
||||
local name=$2
|
||||
local count=$3
|
||||
assert "curl -s http://$host:4040/api/topology/containers?system=show | jq -r '[.nodes | .[] | select(.label_major == \"$name\")] | length'" $count
|
||||
}
|
||||
|
||||
scope_end_suite() {
|
||||
end_suite
|
||||
for host in $HOSTS; do
|
||||
docker_on $host rm -f $(docker_on $host ps -a -q) 2>/dev/null 1>&2 || true
|
||||
done
|
||||
}
|
||||
|
||||
@@ -5,6 +5,6 @@ set -e
|
||||
. ./config.sh
|
||||
|
||||
export PROJECT=scope-integration-tests
|
||||
export TEMPLATE_NAME="test-template-2"
|
||||
export TEMPLATE_NAME="test-template-3"
|
||||
export NUM_HOSTS=2
|
||||
. "$WEAVE_ROOT/test/gce.sh" "$@"
|
||||
|
||||
@@ -16,3 +16,11 @@ for HOST in $HOSTS; do
|
||||
run_on $HOST "sudo curl -sL git.io/weave -o /usr/local/bin/weave"
|
||||
run_on $HOST "sudo chmod a+x /usr/local/bin/weave"
|
||||
done
|
||||
|
||||
echo Prefetching Images
|
||||
for HOST in $HOSTS; do
|
||||
weave_on $HOST setup
|
||||
docker_on $HOST pull peterbourgon/tns-db
|
||||
done
|
||||
|
||||
curl -sL git.io/weave -o ./weave
|
||||
|
||||
Reference in New Issue
Block a user