Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions e2e-tests/nuts-network/gossip/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ echo "------------------------------------"
echo "Performing assertions..."
echo "------------------------------------"

waitForTXCount "NodeA" "http://localhost:18081/status/diagnostics" 81 10
waitForTXCount "NodeD" "http://localhost:48081/status/diagnostics" 81 10
waitForTXCount "NodeA" "http://localhost:18081/status/diagnostics" 81 30
waitForTXCount "NodeD" "http://localhost:48081/status/diagnostics" 81 30

echo "------------------------------------"
echo "Stopping Docker containers..."
Expand Down
27 changes: 18 additions & 9 deletions e2e-tests/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,33 +190,43 @@ urlencode() {
}

# assertJaegerTrace verifies a trace exists with expected services and span patterns
# Fetches trace once and validates all expectations
# Retries while expectations are not met: each node exports spans in batches on its
# own schedule, so a trace may be visible in Jaeger before all services reported.
# Args: Jaeger URL, trace ID, expected services (space-separated), span patterns (space-separated)
function assertJaegerTrace() {
local jaeger_url=$1
local trace_id=$2
local expected_services=$3
local expected_patterns=$4

for attempt in {1..5}; do
local failure=""
for attempt in {1..10}; do
if [ "$attempt" -gt 1 ]; then
sleep 1
fi

local response=$(curl -s -m 10 "$jaeger_url/api/traces/$trace_id")
local trace_count=$(echo "$response" | jq '.data | length')

if [ "$trace_count" -eq 0 ]; then
sleep 1
failure="FAILED: Trace '$trace_id' not found"
continue
fi

local actual_services=$(echo "$response" | jq -r '[.data[0].processes[].serviceName] | unique | sort | join(",")')
local span_names=$(echo "$response" | jq -r '.data[0].spans[].operationName')

# Check each expected service is present
local missing_services=""
for svc in $expected_services; do
if ! echo "$actual_services" | grep -q "$svc"; then
echo "FAILED: Trace '$trace_id' missing service '$svc' (found: $actual_services)" 1>&2
return 1
missing_services="$missing_services $svc"
fi
done
if [ -n "$missing_services" ]; then
failure="FAILED: Trace '$trace_id' missing service(s):$missing_services (found: $actual_services)"
continue
fi

# Check each expected span pattern is present
local missing=""
Expand All @@ -226,16 +236,15 @@ function assertJaegerTrace() {
fi
done
if [ -n "$missing" ]; then
echo "FAILED: Trace '$trace_id' missing spans:$missing" 1>&2
echo "Available: $(echo "$span_names" | sort -u | tr '\n' ', ')" 1>&2
return 1
failure="FAILED: Trace '$trace_id' missing spans:$missing (available: $(echo "$span_names" | sort -u | tr '\n' ','))"
continue
fi

local span_count=$(echo "$response" | jq '.data[0].spans | length')
echo "Verified trace '$trace_id': $span_count spans from $actual_services"
return 0
done

echo "FAILED: Trace '$trace_id' not found after 5 attempts" 1>&2
echo "$failure after 10 attempts" 1>&2
return 1
}
Loading