mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
Add integration test for short lived connections from the internet.
This commit is contained in:
26
integration/300_internet_edge_test.sh
Executable file
26
integration/300_internet_edge_test.sh
Executable file
@@ -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
|
||||
@@ -31,12 +31,12 @@ weave_on() {
|
||||
DOCKER_HOST=tcp://$host:$DOCKER_PORT $WEAVE "$@"
|
||||
}
|
||||
|
||||
# this checks we have a weavescope container
|
||||
# this checks we have a named container
|
||||
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,19 @@ 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")
|
||||
}
|
||||
|
||||
# this checks we have an edge from container 1 to container 2
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user