mirror of
https://github.com/weaveworks/scope.git
synced 2026-02-14 18:09:59 +00:00
tests: add an integration test to check connection thinning
This commit is contained in:
28
integration/321_many_connections_2_test.sh
Executable file
28
integration/321_many_connections_2_test.sh
Executable 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user