Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Wilkie committed Oct 12, 2015
1 parent ffedae6 commit 1577b90
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
8 changes: 7 additions & 1 deletion integration/300_internet_edge_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
5 changes: 4 additions & 1 deletion integration/310_container_to_container_edge_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion integration/320_container_edge_cross_host_2_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions integration/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand All @@ -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
Expand Down

0 comments on commit 1577b90

Please sign in to comment.