mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 01:31:17 +00:00
WIP -- fixing some shellcheck issues in scope
This commit is contained in:
@@ -4,13 +4,13 @@
|
||||
|
||||
start_suite "Launch scope and check it boots"
|
||||
|
||||
weave_on $HOST1 launch
|
||||
scope_on $HOST1 launch
|
||||
weave_on "$HOST1" launch
|
||||
scope_on "$HOST1" launch
|
||||
|
||||
wait_for_containers $HOST1 60 weave weaveproxy weavescope
|
||||
wait_for_containers "$HOST1" 60 weave weaveproxy weavescope
|
||||
|
||||
has_container $HOST1 weave
|
||||
has_container $HOST1 weaveproxy
|
||||
has_container $HOST1 weavescope
|
||||
has_container "$HOST1" weave
|
||||
has_container "$HOST1" weaveproxy
|
||||
has_container "$HOST1" weavescope
|
||||
|
||||
scope_end_suite
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
start_suite "Launch scope (without weave installed) and check it boots"
|
||||
|
||||
scope_on $HOST1 launch
|
||||
scope_on "$HOST1" launch
|
||||
|
||||
wait_for_containers $HOST1 60 weavescope
|
||||
wait_for_containers "$HOST1" 60 weavescope
|
||||
|
||||
has_container $HOST1 weave 0
|
||||
has_container $HOST1 weaveproxy 0
|
||||
has_container $HOST1 weavescope
|
||||
has_container "$HOST1" weave 0
|
||||
has_container "$HOST1" weaveproxy 0
|
||||
has_container "$HOST1" weavescope
|
||||
|
||||
scope_end_suite
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
start_suite "Launch scope and check it boots, with a spurious host arg"
|
||||
|
||||
scope_on $HOST1 launch noatrealhost.foo
|
||||
scope_on "$HOST1" launch noatrealhost.foo
|
||||
|
||||
wait_for_containers $HOST1 60 weavescope
|
||||
wait_for_containers "$HOST1" 60 weavescope
|
||||
|
||||
has_container $HOST1 weavescope
|
||||
has_container "$HOST1" weavescope
|
||||
|
||||
scope_end_suite
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
|
||||
start_suite "Check scope exits cleanly within 5 seconds"
|
||||
|
||||
scope_on $HOST1 launch
|
||||
scope_on "$HOST1" launch
|
||||
sleep 5
|
||||
scope_on $HOST1 stop
|
||||
scope_on "$HOST1" stop
|
||||
|
||||
sleep 5
|
||||
|
||||
# Save stdout for debugging output
|
||||
exec 3>&1
|
||||
exec 3>&1
|
||||
assert_raises "docker_on $HOST1 logs weavescope 2>&1 | grep 'app exiting' || (docker_on $HOST1 logs weavescope 2>&3 ; false)"
|
||||
assert_raises "docker_on $HOST1 logs weavescope 2>&1 | grep 'probe exiting' || (docker_on $HOST1 logs weavescope 2>&3 ; false)"
|
||||
assert_raises "docker_on $HOST1 inspect --format='{{.State.Running}}' weavescope" "false"
|
||||
|
||||
@@ -4,33 +4,33 @@
|
||||
|
||||
start_suite "Test some key topologies are not empty"
|
||||
|
||||
scope_on $HOST1 launch
|
||||
scope_on "$HOST1" launch
|
||||
|
||||
wait_for_containers $HOST1 60 weavescope
|
||||
wait_for_containers "$HOST1" 60 weavescope
|
||||
|
||||
topology_is_not_empty() {
|
||||
local host="$1"
|
||||
local topology="$2"
|
||||
local timeout="${5:-60}"
|
||||
local host="$1"
|
||||
local topology="$2"
|
||||
local timeout="${5:-60}"
|
||||
|
||||
for i in $(seq $timeout); do
|
||||
local report="$(curl -s http://$host:4040/api/report)"
|
||||
local count=$(echo "$report" | jq -r ".$topology.nodes | length > 0" 2>/dev/null)
|
||||
if [ "$count" = "true" ]; then
|
||||
assert "curl -s http://$host:4040/api/report | jq -r '.$topology.nodes | length > 0'" true
|
||||
return
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
for _ in $(seq "$timeout"); do
|
||||
local report="$(curl -s "http://$host:4040/api/report")"
|
||||
local count=$(echo "$report" | jq -r ".$topology.nodes | length > 0" 2>/dev/null)
|
||||
if [ "$count" = "true" ]; then
|
||||
assert "curl -s http://$host:4040/api/report | jq -r '.$topology.nodes | length > 0'" true
|
||||
return
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "Failed to find any nodes in the $topology topology after $timeout secs"
|
||||
assert "curl -s http://$host:4040/api/report | jq -r '.$topology.nodes | length > 0'" true
|
||||
echo "Failed to find any nodes in the $topology topology after $timeout secs"
|
||||
assert "curl -s http://$host:4040/api/report | jq -r '.$topology.nodes | length > 0'" true
|
||||
}
|
||||
|
||||
topology_is_not_empty $HOST1 Endpoint
|
||||
topology_is_not_empty $HOST1 Process
|
||||
topology_is_not_empty $HOST1 Container
|
||||
topology_is_not_empty $HOST1 ContainerImage
|
||||
topology_is_not_empty $HOST1 Host
|
||||
topology_is_not_empty "$HOST1" Endpoint
|
||||
topology_is_not_empty "$HOST1" Process
|
||||
topology_is_not_empty "$HOST1" Container
|
||||
topology_is_not_empty "$HOST1" ContainerImage
|
||||
topology_is_not_empty "$HOST1" Host
|
||||
|
||||
scope_end_suite
|
||||
|
||||
@@ -4,26 +4,26 @@
|
||||
|
||||
start_suite "Launch 2 scopes and check they cluster automatically"
|
||||
|
||||
weave_on $HOST1 launch $HOST1 $HOST2
|
||||
weave_on $HOST2 launch $HOST1 $HOST2
|
||||
weave_on "$HOST1" launch "$HOST1" "$HOST2"
|
||||
weave_on "$HOST2" launch "$HOST1" "$HOST2"
|
||||
|
||||
scope_on $HOST1 launch
|
||||
scope_on $HOST2 launch
|
||||
scope_on "$HOST1" launch
|
||||
scope_on "$HOST2" launch
|
||||
|
||||
docker_on $HOST1 run -dit --name db1 peterbourgon/tns-db
|
||||
docker_on $HOST2 run -dit --name db2 peterbourgon/tns-db
|
||||
docker_on "$HOST1" run -dit --name db1 peterbourgon/tns-db
|
||||
docker_on "$HOST2" run -dit --name db2 peterbourgon/tns-db
|
||||
|
||||
sleep 30 # need to allow the scopes to poll dns, resolve the other app ids, and send them reports
|
||||
|
||||
check() {
|
||||
has_container $1 weave 2
|
||||
has_container $1 weaveproxy 2
|
||||
has_container $1 weavescope 2
|
||||
has_container $1 db1
|
||||
has_container $1 db2
|
||||
has_container "$1" weave 2
|
||||
has_container "$1" weaveproxy 2
|
||||
has_container "$1" weavescope 2
|
||||
has_container "$1" db1
|
||||
has_container "$1" db2
|
||||
}
|
||||
|
||||
check $HOST1
|
||||
check $HOST2
|
||||
check "$HOST1"
|
||||
check "$HOST2"
|
||||
|
||||
scope_end_suite
|
||||
|
||||
@@ -4,23 +4,23 @@
|
||||
|
||||
start_suite "Launch 2 scopes and check they cluster (without weave)"
|
||||
|
||||
scope_on $HOST1 launch $HOST2
|
||||
scope_on $HOST2 launch $HOST1
|
||||
scope_on "$HOST1" launch "$HOST2"
|
||||
scope_on "$HOST2" launch "$HOST1"
|
||||
|
||||
docker_on $HOST1 run -dit --name db1 peterbourgon/tns-db
|
||||
docker_on $HOST2 run -dit --name db2 peterbourgon/tns-db
|
||||
docker_on "$HOST1" run -dit --name db1 peterbourgon/tns-db
|
||||
docker_on "$HOST2" run -dit --name db2 peterbourgon/tns-db
|
||||
|
||||
sleep 30 # need to allow the scopes to poll dns, resolve the other app ids, and send them reports.
|
||||
|
||||
check() {
|
||||
has_container $1 weave 0
|
||||
has_container $1 weaveproxy 0
|
||||
has_container $1 weavescope 2
|
||||
has_container $1 db1
|
||||
has_container $1 db2
|
||||
has_container "$1" weave 0
|
||||
has_container "$1" weaveproxy 0
|
||||
has_container "$1" weavescope 2
|
||||
has_container "$1" db1
|
||||
has_container "$1" db2
|
||||
}
|
||||
|
||||
check $HOST1
|
||||
check $HOST2
|
||||
check "$HOST1"
|
||||
check "$HOST2"
|
||||
|
||||
scope_end_suite
|
||||
|
||||
@@ -4,26 +4,26 @@
|
||||
|
||||
start_suite "Launch 2 scopes and check they cluster automatically, with custom weave domain"
|
||||
|
||||
weave_on $HOST1 launch --dns-domain foo.local $HOST1 $HOST2
|
||||
weave_on $HOST2 launch --dns-domain foo.local $HOST1 $HOST2
|
||||
weave_on "$HOST1" launch --dns-domain foo.local "$HOST1" "$HOST2"
|
||||
weave_on "$HOST2" launch --dns-domain foo.local "$HOST1" "$HOST2"
|
||||
|
||||
scope_on $HOST1 launch --weave.hostname=bar.foo.local
|
||||
scope_on $HOST2 launch --weave.hostname bar.foo.local
|
||||
scope_on "$HOST1" launch --weave.hostname=bar.foo.local
|
||||
scope_on "$HOST2" launch --weave.hostname bar.foo.local
|
||||
|
||||
docker_on $HOST1 run -dit --name db1 peterbourgon/tns-db
|
||||
docker_on $HOST2 run -dit --name db2 peterbourgon/tns-db
|
||||
docker_on "$HOST1" run -dit --name db1 peterbourgon/tns-db
|
||||
docker_on "$HOST2" run -dit --name db2 peterbourgon/tns-db
|
||||
|
||||
sleep 30 # need to allow the scopes to poll dns, resolve the other app ids, and send them reports
|
||||
|
||||
check() {
|
||||
has_container $1 weave 2
|
||||
has_container $1 weaveproxy 2
|
||||
has_container $1 weavescope 2
|
||||
has_container $1 db1
|
||||
has_container $1 db2
|
||||
has_container "$1" weave 2
|
||||
has_container "$1" weaveproxy 2
|
||||
has_container "$1" weavescope 2
|
||||
has_container "$1" db1
|
||||
has_container "$1" db2
|
||||
}
|
||||
|
||||
check $HOST1
|
||||
check $HOST2
|
||||
check "$HOST1"
|
||||
check "$HOST2"
|
||||
|
||||
scope_end_suite
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
|
||||
start_suite "Launch 2 scopes and check they cluster (without weave)"
|
||||
|
||||
scope_on $HOST1 launch --no-app $HOST2
|
||||
scope_on $HOST2 launch --no-probe
|
||||
scope_on "$HOST1" launch --no-app "$HOST2"
|
||||
scope_on "$HOST2" launch --no-probe
|
||||
|
||||
docker_on $HOST1 run -dit --name db1 peterbourgon/tns-db
|
||||
docker_on "$HOST1" run -dit --name db1 peterbourgon/tns-db
|
||||
|
||||
sleep 30 # need to allow the scopes to poll dns, resolve the other app ids, and send them reports.
|
||||
|
||||
has_container $HOST2 weavescope
|
||||
has_container $HOST2 db1
|
||||
has_container "$HOST2" weavescope
|
||||
has_container "$HOST2" db1
|
||||
|
||||
scope_end_suite
|
||||
|
||||
@@ -5,26 +5,26 @@
|
||||
start_suite "Test short lived connections from the Internet"
|
||||
|
||||
if ! echo "$HOST1" | grep "us-central1-a"; then
|
||||
echo "Skipping; test needs to be run against VMs on GCE."
|
||||
scope_end_suite
|
||||
exit
|
||||
echo "Skipping; test needs to be run against VMs on GCE."
|
||||
scope_end_suite
|
||||
exit
|
||||
fi
|
||||
|
||||
weave_on $HOST1 launch
|
||||
scope_on $HOST1 launch
|
||||
docker_on $HOST1 run -d -p 80:80 --name nginx nginx
|
||||
weave_on "$HOST1" launch
|
||||
scope_on "$HOST1" launch
|
||||
docker_on "$HOST1" run -d -p 80:80 --name nginx nginx
|
||||
|
||||
do_connections() {
|
||||
while true; do
|
||||
curl -s http://$HOST1:80/ >/dev/null || true
|
||||
sleep 1
|
||||
done
|
||||
while true; do
|
||||
curl -s "http://$HOST1:80/" >/dev/null || true
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
do_connections&
|
||||
do_connections &
|
||||
|
||||
wait_for_containers $HOST1 60 nginx "The Internet"
|
||||
wait_for_containers "$HOST1" 60 nginx "The Internet"
|
||||
|
||||
has_connection_by_id containers $HOST1 "in-theinternet" $(node_id containers $HOST1 nginx)
|
||||
has_connection_by_id containers "$HOST1" "in-theinternet" "$(node_id containers "$HOST1" nginx)"
|
||||
|
||||
kill %do_connections
|
||||
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
|
||||
start_suite "Test short lived connections between containers"
|
||||
|
||||
weave_on $HOST1 launch
|
||||
scope_on $HOST1 launch
|
||||
weave_on $HOST1 run -d --name nginx nginx
|
||||
weave_on $HOST1 run -d --name client alpine /bin/sh -c "while true; do \
|
||||
weave_on "$HOST1" launch
|
||||
scope_on "$HOST1" launch
|
||||
weave_on "$HOST1" run -d --name nginx nginx
|
||||
weave_on "$HOST1" run -d --name client alpine /bin/sh -c "while true; do \
|
||||
wget http://nginx.weave.local:80/ -O - >/dev/null || true; \
|
||||
sleep 1; \
|
||||
done"
|
||||
|
||||
wait_for_containers $HOST1 60 nginx client
|
||||
wait_for_containers "$HOST1" 60 nginx client
|
||||
|
||||
has_container $HOST1 nginx
|
||||
has_container $HOST1 client
|
||||
has_connection containers $HOST1 client nginx
|
||||
has_container "$HOST1" nginx
|
||||
has_container "$HOST1" client
|
||||
has_connection containers "$HOST1" client nginx
|
||||
|
||||
scope_end_suite
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
|
||||
start_suite "Test short lived connections between containers on different hosts"
|
||||
|
||||
weave_on $HOST1 launch $HOST1 $HOST2
|
||||
weave_on $HOST2 launch $HOST1 $HOST2
|
||||
weave_on "$HOST1" launch "$HOST1" "$HOST2"
|
||||
weave_on "$HOST2" launch "$HOST1" "$HOST2"
|
||||
|
||||
scope_on $HOST1 launch
|
||||
scope_on $HOST2 launch
|
||||
scope_on "$HOST1" launch
|
||||
scope_on "$HOST2" launch
|
||||
|
||||
weave_on $HOST1 run -d --name nginx nginx
|
||||
weave_on $HOST2 run -d --name client alpine /bin/sh -c "while true; do \
|
||||
weave_on "$HOST1" run -d --name nginx nginx
|
||||
weave_on "$HOST2" run -d --name client alpine /bin/sh -c "while true; do \
|
||||
wget http://nginx.weave.local:80/ -O - >/dev/null || true; \
|
||||
sleep 1; \
|
||||
done"
|
||||
@@ -19,12 +19,12 @@ done"
|
||||
sleep 30 # need to allow the scopes to poll dns, resolve the other app ids, and send them reports
|
||||
|
||||
check() {
|
||||
has_container $1 nginx
|
||||
has_container $1 client
|
||||
has_connection containers $1 client nginx
|
||||
has_container "$1" nginx
|
||||
has_container "$1" client
|
||||
has_connection containers "$1" client nginx
|
||||
}
|
||||
|
||||
check $HOST1
|
||||
check $HOST2
|
||||
check "$HOST1"
|
||||
check "$HOST2"
|
||||
|
||||
scope_end_suite
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
|
||||
start_suite "Test long connections (procspy) between processes"
|
||||
|
||||
weave_on $HOST1 launch
|
||||
scope_on $HOST1 launch --probe.conntrack=false
|
||||
weave_on $HOST1 run -d --name nginx nginx
|
||||
weave_on $HOST1 run -dti --name client alpine /bin/sh -c "while true; do \
|
||||
weave_on "$HOST1" launch
|
||||
scope_on "$HOST1" launch --probe.conntrack=false
|
||||
weave_on "$HOST1" run -d --name nginx nginx
|
||||
weave_on "$HOST1" run -dti --name client alpine /bin/sh -c "while true; do \
|
||||
nc nginx.weave.local 80 || true; \
|
||||
sleep 1; \
|
||||
done"
|
||||
|
||||
wait_for processes $HOST1 60 "nginx: worker process" nc
|
||||
wait_for processes "$HOST1" 60 "nginx: worker process" nc
|
||||
|
||||
has processes $HOST1 "nginx: worker process"
|
||||
has processes $HOST1 nc
|
||||
has_connection processes $HOST1 nc "nginx: worker process"
|
||||
has processes "$HOST1" "nginx: worker process"
|
||||
has processes "$HOST1" nc
|
||||
has_connection processes "$HOST1" nc "nginx: worker process"
|
||||
|
||||
scope_end_suite
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
|
||||
start_suite "Test long connections (procspy) between processes on different hosts"
|
||||
|
||||
weave_on $HOST1 launch $HOST1 $HOST2
|
||||
weave_on $HOST2 launch $HOST1 $HOST2
|
||||
weave_on "$HOST1" launch "$HOST1" "$HOST2"
|
||||
weave_on "$HOST2" launch "$HOST1" "$HOST2"
|
||||
|
||||
scope_on $HOST1 launch --probe.conntrack=false
|
||||
scope_on $HOST2 launch --probe.conntrack=false
|
||||
scope_on "$HOST1" launch --probe.conntrack=false
|
||||
scope_on "$HOST2" launch --probe.conntrack=false
|
||||
|
||||
weave_on $HOST1 run -d --name nginx nginx
|
||||
weave_on $HOST2 run -dti --name client alpine /bin/sh -c "while true; do \
|
||||
weave_on "$HOST1" run -d --name nginx nginx
|
||||
weave_on "$HOST2" run -dti --name client alpine /bin/sh -c "while true; do \
|
||||
nc nginx.weave.local 80 || true; \
|
||||
sleep 1; \
|
||||
done"
|
||||
@@ -19,12 +19,12 @@ done"
|
||||
sleep 30 # need to allow the scopes to poll dns, resolve the other app ids, and send them reports
|
||||
|
||||
check() {
|
||||
has processes $1 "nginx: worker process"
|
||||
has processes $1 nc
|
||||
has_connection processes $1 nc "nginx: worker process"
|
||||
has processes "$1" "nginx: worker process"
|
||||
has processes "$1" nc
|
||||
has_connection processes "$1" nc "nginx: worker process"
|
||||
}
|
||||
|
||||
check $HOST1
|
||||
check $HOST2
|
||||
check "$HOST1"
|
||||
check "$HOST2"
|
||||
|
||||
scope_end_suite
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
|
||||
start_suite "Test container controls"
|
||||
|
||||
weave_on $HOST1 launch
|
||||
scope_on $HOST1 launch
|
||||
weave_on "$HOST1" launch
|
||||
scope_on "$HOST1" launch
|
||||
|
||||
CID=$(weave_on $HOST1 run -dti --name alpine alpine /bin/sh)
|
||||
CID=$(weave_on "$HOST1" run -dti --name alpine alpine /bin/sh)
|
||||
|
||||
wait_for_containers $HOST1 60 alpine
|
||||
wait_for_containers "$HOST1" 60 alpine
|
||||
|
||||
assert "docker_on $HOST1 inspect --format='{{.State.Running}}' alpine" "true"
|
||||
PROBEID=$(docker_on $HOST1 logs weavescope 2>&1 | grep "probe starting" | sed -n 's/^.*ID \([0-9a-f]*\)$/\1/p')
|
||||
PROBEID=$(docker_on "$HOST1" logs weavescope 2>&1 | grep "probe starting" | sed -n 's/^.*ID \([0-9a-f]*\)$/\1/p')
|
||||
|
||||
# Execute 'echo foo' in a container tty and check its output
|
||||
PIPEID=$(curl -s -f -X POST "http://$HOST1:4040/api/control/$PROBEID/$CID;<container>/docker_exec_container" | jq -r '.pipe' )
|
||||
PIPEID=$(curl -s -f -X POST "http://$HOST1:4040/api/control/$PROBEID/$CID;<container>/docker_exec_container" | jq -r '.pipe')
|
||||
assert "(sleep 1 && echo 'echo foo' && sleep 1) | wscat -b 'ws://$HOST1:4040/api/pipe/$PIPEID' | col -pb" "alpine:/# 6necho foo\nfoo\nalpine:/# 6n"
|
||||
|
||||
assert_raises "curl -f -X POST 'http://$HOST1:4040/api/control/$PROBEID/$CID;<container>/docker_stop_container'"
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
|
||||
start_suite "Test host controls"
|
||||
|
||||
weave_on $HOST1 launch
|
||||
scope_on $HOST1 launch
|
||||
weave_on "$HOST1" launch
|
||||
scope_on "$HOST1" launch
|
||||
|
||||
sleep 10
|
||||
|
||||
PROBEID=$(docker_on $HOST1 logs weavescope 2>&1 | grep "probe starting" | sed -n 's/^.*ID \([0-9a-f]*\)$/\1/p')
|
||||
HOSTID=$($SSH $HOST1 hostname)
|
||||
PROBEID=$(docker_on "$HOST1" logs weavescope 2>&1 | grep "probe starting" | sed -n 's/^.*ID \([0-9a-f]*\)$/\1/p')
|
||||
HOSTID=$(sshcmd "$HOST1" hostname)
|
||||
|
||||
# Execute 'echo foo' in the host tty and check its output
|
||||
PIPEID=$(curl -s -f -X POST "http://$HOST1:4040/api/control/$PROBEID/$HOSTID;<host>/host_exec" | jq -r '.pipe' )
|
||||
PIPEID=$(curl -s -f -X POST "http://$HOST1:4040/api/control/$PROBEID/$HOSTID;<host>/host_exec" | jq -r '.pipe')
|
||||
assert "(sleep 1 && echo \"PS1=''; echo foo\" && sleep 1) | wscat -b 'ws://$HOST1:4040/api/pipe/$PIPEID' | col -pb | tail -n 1" "foo\n"
|
||||
|
||||
scope_end_suite
|
||||
|
||||
@@ -13,45 +13,45 @@ WEAVE="./weave"
|
||||
SCOPE="../scope"
|
||||
|
||||
scope_on() {
|
||||
local host=$1
|
||||
shift 1
|
||||
[ -z "$DEBUG" ] || greyly echo "Scope on $host: $@" >&2
|
||||
DOCKER_HOST=tcp://$host:$DOCKER_PORT CHECKPOINT_DISABLE=true $SCOPE "$@"
|
||||
local host=$1
|
||||
shift 1
|
||||
[ -z "$DEBUG" ] || greyly echo "Scope on $host: $*" >&2
|
||||
DOCKER_HOST=tcp://$host:$DOCKER_PORT CHECKPOINT_DISABLE=true "$SCOPE" "$@"
|
||||
}
|
||||
|
||||
weave_on() {
|
||||
local host=$1
|
||||
shift 1
|
||||
[ -z "$DEBUG" ] || greyly echo "Weave on $host: $@" >&2
|
||||
DOCKER_HOST=tcp://$host:$DOCKER_PORT CHECKPOINT_DISABLE=true $WEAVE "$@"
|
||||
local host=$1
|
||||
shift 1
|
||||
[ -z "$DEBUG" ] || greyly echo "Weave on $host: $*" >&2
|
||||
DOCKER_HOST=tcp://$host:$DOCKER_PORT CHECKPOINT_DISABLE=true $WEAVE "$@"
|
||||
}
|
||||
|
||||
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
|
||||
end_suite
|
||||
for host in $HOSTS; do
|
||||
(docker_on "$host" ps -a -q | xargs docker_on "$host" rm -f) 2>/dev/null 1>&2 || true
|
||||
done
|
||||
}
|
||||
|
||||
# this checks we have a named node in the given view
|
||||
has() {
|
||||
local view=$1
|
||||
local host=$2
|
||||
local name=$3
|
||||
local count=${4:-1}
|
||||
assert "curl -s http://${host}:4040/api/topology/${view}?system=show | jq -r '[.nodes[] | select(.label == \"${name}\")] | length'" $count
|
||||
local view=$1
|
||||
local host=$2
|
||||
local name=$3
|
||||
local count=${4:-1}
|
||||
assert "curl -s http://${host}:4040/api/topology/${view}?system=show | jq -r '[.nodes[] | select(.label == \"${name}\")] | length'" "$count"
|
||||
}
|
||||
|
||||
# this checks we have a named container
|
||||
has_container() {
|
||||
has containers "$@"
|
||||
has containers "$@"
|
||||
}
|
||||
|
||||
node_id() {
|
||||
local view="$1"
|
||||
local host="$2"
|
||||
local name="$3"
|
||||
echo $(curl -s http://${host}:4040/api/topology/${view}?system=show | jq -r ".nodes[] | select(.label == \"${name}\") | .id")
|
||||
local host="$2"
|
||||
local name="$3"
|
||||
curl -s "http://${host}:4040/api/topology/${view}?system=show" | jq -r ".nodes[] | select(.label == \"${name}\") | .id"
|
||||
}
|
||||
|
||||
container_id() {
|
||||
@@ -60,33 +60,33 @@ container_id() {
|
||||
|
||||
# this checks we have an edge from container 1 to container 2
|
||||
has_connection_by_id() {
|
||||
local view="$1"
|
||||
local host="$2"
|
||||
local from_id="$3"
|
||||
local to_id="$4"
|
||||
local timeout="${5:-60}"
|
||||
local view="$1"
|
||||
local host="$2"
|
||||
local from_id="$3"
|
||||
local to_id="$4"
|
||||
local timeout="${5:-60}"
|
||||
|
||||
for i in $(seq $timeout); do
|
||||
local nodes="$(curl -s http://$host:4040/api/topology/${view}?system=show)"
|
||||
local edge=$(echo "$nodes" | jq -r ".nodes[\"$from_id\"].adjacency | contains([\"$to_id\"])" 2>/dev/null)
|
||||
if [ "$edge" = "true" ]; then
|
||||
echo "Found edge $from -> $to after $i secs"
|
||||
assert "curl -s http://$host:4040/api/topology/${view}?system=show | jq -r '.nodes[\"$from_id\"].adjacency | contains([\"$to_id\"])'" true
|
||||
return
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
for i in $(seq "$timeout"); do
|
||||
local nodes="$(curl -s "http://$host:4040/api/topology/${view}?system=show")"
|
||||
local edge=$(echo "$nodes" | jq -r ".nodes[\"$from_id\"].adjacency | contains([\"$to_id\"])" 2>/dev/null)
|
||||
if [ "$edge" = "true" ]; then
|
||||
echo "Found edge $from -> $to after $i secs"
|
||||
assert "curl -s http://$host:4040/api/topology/${view}?system=show | jq -r '.nodes[\"$from_id\"].adjacency | contains([\"$to_id\"])'" true
|
||||
return
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "Failed to find edge $from -> $to after $timeout secs"
|
||||
assert "curl -s http://$host:4040/api/topology/${view}?system=show | jq -r '.nodes[\"$from_id\"].adjacency | contains([\"$to_id\"])'" true
|
||||
echo "Failed to find edge $from -> $to after $timeout secs"
|
||||
assert "curl -s http://$host:4040/api/topology/${view}?system=show | jq -r '.nodes[\"$from_id\"].adjacency | contains([\"$to_id\"])'" true
|
||||
}
|
||||
|
||||
has_connection() {
|
||||
local view="$1"
|
||||
local host="$2"
|
||||
local from="$3"
|
||||
local to="$4"
|
||||
local timeout="${5:-60}"
|
||||
local view="$1"
|
||||
local host="$2"
|
||||
local from="$3"
|
||||
local to="$4"
|
||||
local timeout="${5:-60}"
|
||||
local from_id="$(node_id "${view}" "${host}" "${from}")"
|
||||
local to_id="$(node_id "${view}" "${host}" "${to}")"
|
||||
|
||||
@@ -94,33 +94,32 @@ has_connection() {
|
||||
}
|
||||
|
||||
wait_for() {
|
||||
local view="$1"
|
||||
local host="$2"
|
||||
local timeout="$3"
|
||||
shift 3
|
||||
local view="$1"
|
||||
local host="$2"
|
||||
local timeout="$3"
|
||||
shift 3
|
||||
|
||||
for i in $(seq ${timeout}); do
|
||||
local nodes="$(curl -s http://$host:4040/api/topology/${view}?system=show)"
|
||||
local found=0
|
||||
for name in "$@"; do
|
||||
local count=$(echo "${nodes}" | jq -r "[.nodes[] | select(.label == \"${name}\")] | length")
|
||||
if [ -n "${count}" ] && [ "${count}" -ge 1 ]; then
|
||||
found=$(( found + 1 ))
|
||||
fi
|
||||
done
|
||||
for i in $(seq "${timeout}"); do
|
||||
local nodes="$(curl -s "http://$host:4040/api/topology/${view}?system=show")"
|
||||
local found=0
|
||||
for name in "$@"; do
|
||||
local count=$(echo "${nodes}" | jq -r "[.nodes[] | select(.label == \"${name}\")] | length")
|
||||
if [ -n "${count}" ] && [ "${count}" -ge 1 ]; then
|
||||
found=$((found + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${found}" -eq $# ]; then
|
||||
echo "Found ${found} nodes after $i secs"
|
||||
return
|
||||
fi
|
||||
if [ "${found}" -eq $# ]; then
|
||||
echo "Found $found nodes after $i secs"
|
||||
return
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "Failed to find nodes $@ after $i secs"
|
||||
echo "Failed to find nodes $* after $i secs"
|
||||
}
|
||||
|
||||
|
||||
wait_for_containers() {
|
||||
wait_for containers "$@"
|
||||
wait_for containers "$@"
|
||||
}
|
||||
|
||||
@@ -7,28 +7,28 @@ set -e # NB don't set -u, as weave's config.sh doesn't like that.
|
||||
echo Copying scope images and scripts to hosts
|
||||
for HOST in $HOSTS; do
|
||||
SIZE=$(stat --printf="%s" ../scope.tar)
|
||||
cat ../scope.tar | pv -N "scope.tar" -s $SIZE | $SSH -C $HOST sudo docker load
|
||||
pv <../scope.tar -N "scope.tar" -s "$SIZE" | sshcmd -C "$HOST" sudo docker load
|
||||
done
|
||||
|
||||
setup_host() {
|
||||
local HOST=$1
|
||||
echo Installing weave on $HOST
|
||||
echo Installing weave on "$HOST"
|
||||
# Download the latest released weave script locally,
|
||||
# for use by weave_on
|
||||
curl -sL git.io/weave -o ./weave
|
||||
chmod a+x ./weave
|
||||
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"
|
||||
weave_on $HOST setup
|
||||
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"
|
||||
weave_on "$HOST" setup
|
||||
|
||||
echo Prefetching Images on $HOST
|
||||
docker_on $HOST pull peterbourgon/tns-db
|
||||
docker_on $HOST pull alpine
|
||||
docker_on $HOST pull nginx
|
||||
echo Prefetching Images on "$HOST"
|
||||
docker_on "$HOST" pull peterbourgon/tns-db
|
||||
docker_on "$HOST" pull alpine
|
||||
docker_on "$HOST" pull nginx
|
||||
}
|
||||
|
||||
for HOST in $HOSTS; do
|
||||
setup_host $HOST &
|
||||
setup_host "$HOST" &
|
||||
done
|
||||
|
||||
wait
|
||||
|
||||
Reference in New Issue
Block a user