diff --git a/integration/300_internet_edge_test.sh b/integration/300_internet_edge_test.sh new file mode 100755 index 0000000000..1b3a61a5d7 --- /dev/null +++ b/integration/300_internet_edge_test.sh @@ -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 diff --git a/integration/config.sh b/integration/config.sh index 84769111f1..be53db61d0 100644 --- a/integration/config.sh +++ b/integration/config.sh @@ -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() { @@ -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 +}