Skip to content

Commit

Permalink
Add integration test for short lived connections from the internet.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Wilkie committed Oct 2, 2015
1 parent d3aa975 commit b613f33
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
26 changes: 26 additions & 0 deletions integration/300_internet_edge_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#! /bin/bash

. ./config.sh

start_suite "Test short lived connections from the Internet"

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
sleep 1
done
}
do_connections&

sleep 5 # give the probe a few seconds to build a report and send it to the app

has_container $HOST1 nginx 1
has_connection $HOST1 "The Internet" nginx

kill %do_connections

scope_end_suite
17 changes: 16 additions & 1 deletion integration/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ 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
assert "curl -s http://$host:4040/api/topology/containers?system=show | jq -r '[.nodes[] | select(.label_major == \"$name\")] | length'" $count
}

scope_end_suite() {
Expand All @@ -45,3 +45,18 @@ scope_end_suite() {
docker_on $host rm -f $(docker_on $host ps -a -q) 2>/dev/null 1>&2 || true
done
}

container_id() {
local host="$1"
local name="$2"
echo $(curl -s http://$host:4040/api/topology/containers?system=show | jq -r ".nodes[] | select(.label_major == \"$name\") | .id")
}

has_connection() {
local host="$1"
local from="$2"
local to="$3"
local from_id=$(container_id "$host" "$from")
local to_id=$(container_id "$host" "$to")
assert "curl -s http://$host:4040/api/topology/containers?system=show | jq -r '.nodes[\"$from_id\"].adjacency | contains([\"$to_id\"])'" true
}

0 comments on commit b613f33

Please sign in to comment.