tests: add an integration test to check connection thinning

This commit is contained in:
Bryan Boreham
2019-10-24 18:55:01 +00:00
parent b7b245ed48
commit de939cc39b
2 changed files with 32 additions and 2 deletions

View File

@@ -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

View File

@@ -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