History

fix: make service log regression assertions deterministic

The all-source query asserted an early healthy-log event survived an unfiltered --tail 100 while the intentionally broken service kept crash-looping and appending records, so the check raced the flood. Filter with --grep before the tail so eviction of unrelated events cannot fail the assertion. Both service log assertions also relied on jq -e select() over a multi-record JSONL stream, whose exit status tracks the final record rather than whether any record matched. Slurp and assert any() instead.

Ben Davis committed 3 months ago

Commit 3e7089b1 parent b8328651 file · +8 −4Browse files

Showing the changes to tests (1 of 1 file). Show all

Unified · Split

tests/regressions-services.sh+8−4
@@ -473,17 +473,21 @@ after_early="$(wc -l <"$events/broken.starts" | tr -d ' ')" · 472 unmodified lines
473473 wait_for_count $((before + 1)) "$events/broken.starts"
474474 [[ "$(wc -l <"$events/healthy.starts" | tr -d ' ')" == 1 ]]
475475
476−# Each custom source is independently queryable, and `all` includes it.
476+# Each custom source is independently queryable, and `all` includes it. The
477+# crash-looping broken service floods the shared stream, so the all-source
478+# check filters before the tail; an unfiltered tail legitimately evicts old
479+# events. Assertions aggregate the stream: a matching record must exist even
480+# when later records differ.
477481 wait_for_pattern healthy-log "$logs/service-healthy.jsonl"
478482 "$PROJECT_ROOT/guest/tx9-logs" query --agent-root "$data" \
479483 --executor-root "$tmp/empty-executor" --box fixture --source service-healthy \
480484 --tail 100 --json >"$tmp/service-query.jsonl"
481−jq -e 'select(.source == "service-healthy" and .message == "healthy-log")' \
485+jq -se 'any(.[]; .source == "service-healthy" and .message == "healthy-log")' \
482486 "$tmp/service-query.jsonl" >/dev/null
483487 "$PROJECT_ROOT/guest/tx9-logs" query --agent-root "$data" \
484488 --executor-root "$tmp/empty-executor" --box fixture --source all \
485− --tail 100 --json >"$tmp/all-query.jsonl"
486−jq -e 'select(.source == "service-healthy" and .message == "healthy-log")' \
489+ --grep healthy-log --tail 100 --json >"$tmp/all-query.jsonl"
490+jq -se 'any(.[]; .source == "service-healthy" and .message == "healthy-log")' \
487491 "$tmp/all-query.jsonl" >/dev/null
488492
489493 # Removing execute permission removes the desired service and synchronously