mirror of
https://github.com/weaveworks/scope.git
synced 2026-02-15 10:29:51 +00:00
Review feedback
This commit is contained in:
@@ -4,6 +4,12 @@
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
weave_on $HOST1 launch
|
||||
scope_on $HOST1 launch
|
||||
docker_on $HOST1 run -d -p 80:80 --name nginx nginx
|
||||
@@ -20,7 +26,7 @@ wait_for_containers $HOST1 60 nginx "The Internet"
|
||||
|
||||
has_container $HOST1 nginx
|
||||
has_container $HOST1 "The Internet"
|
||||
has_connection $HOST1 "The Internet" nginx 60
|
||||
has_connection $HOST1 "The Internet" nginx
|
||||
|
||||
kill %do_connections
|
||||
|
||||
|
||||
@@ -7,7 +7,10 @@ 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 wget http://nginx.weave.local:80/ >/dev/null; sleep 1; done"
|
||||
weave_on $HOST1 run -d --name client alpine /bin/sh -c "while true; do \
|
||||
wget http://nginx.weave.local:80/ >/dev/null || true; \
|
||||
sleep 1; \
|
||||
done"
|
||||
|
||||
wait_for_containers $HOST1 60 nginx client
|
||||
|
||||
|
||||
@@ -11,7 +11,10 @@ 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 wget http://nginx.weave.local:80/ >/dev/null; sleep 1; done"
|
||||
weave_on $HOST2 run -d --name client alpine /bin/sh -c "while true; do \
|
||||
wget http://nginx.weave.local:80/ >/dev/null || true; \
|
||||
sleep 1; \
|
||||
done"
|
||||
|
||||
sleep 30 # need to allow the scopes to poll dns, resolve the other app ids, and send them reports
|
||||
|
||||
|
||||
@@ -57,13 +57,13 @@ has_connection() {
|
||||
local host="$1"
|
||||
local from="$2"
|
||||
local to="$3"
|
||||
local timeout="${4:-10}"
|
||||
local timeout="${4:-60}"
|
||||
local from_id=$(container_id "$host" "$from")
|
||||
local to_id=$(container_id "$host" "$to")
|
||||
|
||||
for i in $(seq $timeout); do
|
||||
local containers="$(curl -s http://$host:4040/api/topology/containers?system=show)"
|
||||
local edge=$(echo "$containers" | jq -r ".nodes[\"$from_id\"].adjacency | contains([\"$to_id\"])")
|
||||
local edge=$(echo "$containers" | 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/containers?system=show | jq -r '.nodes[\"$from_id\"].adjacency | contains([\"$to_id\"])'" true
|
||||
@@ -72,7 +72,7 @@ has_connection() {
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "Failed to fing edge $from -> $to after $timeout secs"
|
||||
echo "Failed to find edge $from -> $to after $timeout secs"
|
||||
assert "curl -s http://$host:4040/api/topology/containers?system=show | jq -r '.nodes[\"$from_id\"].adjacency | contains([\"$to_id\"])'" true
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ wait_for_containers() {
|
||||
local found=0
|
||||
for name in "$@"; do
|
||||
local count=$(echo "$containers" | jq -r "[.nodes[] | select(.label_major == \"$name\")] | length")
|
||||
if [ "$count" -ge 1 ]; then
|
||||
if [ -n "$count" ] && [ "$count" -ge 1 ]; then
|
||||
found=$(( found + 1 ))
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user