Skip to content

Commit de939cc

Browse files
committed
tests: add an integration test to check connection thinning
1 parent b7b245e commit de939cc

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#! /bin/bash
2+
3+
# shellcheck disable=SC1091
4+
. ./config.sh
5+
6+
start_suite "Test short lived connections between containers on different hosts"
7+
8+
weave_on "$HOST1" launch "$HOST1" "$HOST2"
9+
weave_on "$HOST2" launch "$HOST1" "$HOST2"
10+
11+
scope_on "$HOST1" launch
12+
scope_on "$HOST2" launch
13+
14+
server_on "$HOST1"
15+
client_on "$HOST2"
16+
17+
sleep 30 # need to allow the scopes to poll dns, resolve the other app ids, and send them reports
18+
19+
check() {
20+
has_container "$1" nginx
21+
has_container "$1" client
22+
has_connection containers "$1" client nginx
23+
}
24+
25+
check "$HOST1"
26+
check "$HOST2"
27+
28+
scope_end_suite

integration/config.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,17 @@ has_connection_by_id() {
109109
local from_id="$3"
110110
local to_id="$4"
111111
local timeout="${5:-60}"
112+
local max_edges="$6:10"
112113

113114
for i in $(seq "$timeout"); do
114115
local nodes
115116
local edge
116-
edge=$(echo "$nodes" | (jq -r ".nodes[\"$from_id\"].adjacency | contains([\"$to_id\"])" || true) 2>/dev/null)
117117
nodes=$(curl -s "http://$host:4040/api/topology/${view}?system=show" || true)
118+
edge=$(echo "$nodes" | (jq -r ".nodes[\"$from_id\"].adjacency | contains([\"$to_id\"])" || true) 2>/dev/null)
118119
if [ "$edge" = "true" ]; then
119120
echo "Found edge $from -> $to after $i secs"
120-
assert "curl -s http://$host:4040/api/topology/${view}?system=show | jq -r '.nodes[\"$from_id\"].adjacency | contains([\"$to_id\"])'" true
121+
count=$(echo "$nodes" | jq -r ".nodes[\"$from_id\"].adjacency | length" 2>/dev/null)
122+
assert "[ $count -le $max_edges ]"
121123
return
122124
fi
123125
sleep 1

0 commit comments

Comments
 (0)