From de939cc39b1bb66ff5be18ff4765dd3e93c30710 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 24 Oct 2019 18:55:01 +0000 Subject: [PATCH] tests: add an integration test to check connection thinning --- integration/321_many_connections_2_test.sh | 28 ++++++++++++++++++++++ integration/config.sh | 6 +++-- 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100755 integration/321_many_connections_2_test.sh diff --git a/integration/321_many_connections_2_test.sh b/integration/321_many_connections_2_test.sh new file mode 100755 index 000000000..4e0a057a9 --- /dev/null +++ b/integration/321_many_connections_2_test.sh @@ -0,0 +1,28 @@ +#! /bin/bash + +# shellcheck disable=SC1091 +. ./config.sh + +start_suite "Test short lived connections between containers on different hosts" + +weave_on "$HOST1" launch "$HOST1" "$HOST2" +weave_on "$HOST2" launch "$HOST1" "$HOST2" + +scope_on "$HOST1" launch +scope_on "$HOST2" launch + +server_on "$HOST1" +client_on "$HOST2" + +sleep 30 # need to allow the scopes to poll dns, resolve the other app ids, and send them reports + +check() { + has_container "$1" nginx + has_container "$1" client + has_connection containers "$1" client nginx +} + +check "$HOST1" +check "$HOST2" + +scope_end_suite diff --git a/integration/config.sh b/integration/config.sh index 01b2eb5bc..d51ee9999 100644 --- a/integration/config.sh +++ b/integration/config.sh @@ -109,15 +109,17 @@ has_connection_by_id() { local from_id="$3" local to_id="$4" local timeout="${5:-60}" + local max_edges="$6:10" for i in $(seq "$timeout"); do local nodes local edge - edge=$(echo "$nodes" | (jq -r ".nodes[\"$from_id\"].adjacency | contains([\"$to_id\"])" || true) 2>/dev/null) nodes=$(curl -s "http://$host:4040/api/topology/${view}?system=show" || true) + edge=$(echo "$nodes" | (jq -r ".nodes[\"$from_id\"].adjacency | contains([\"$to_id\"])" || true) 2>/dev/null) if [ "$edge" = "true" ]; then echo "Found edge $from -> $to after $i secs" - assert "curl -s http://$host:4040/api/topology/${view}?system=show | jq -r '.nodes[\"$from_id\"].adjacency | contains([\"$to_id\"])'" true + count=$(echo "$nodes" | jq -r ".nodes[\"$from_id\"].adjacency | length" 2>/dev/null) + assert "[ $count -le $max_edges ]" return fi sleep 1