Skip to content

Commit 5851fe4

Browse files
author
Scaffold Bot
committed
fix(test): parse cache_size=N/M format in stateless-demo-04 test
The service outputs cache_size=4/4 (size/capacity in one field) but the test expected a separate cache_capacity= field. Extract capacity from the denominator as a fallback, and guard all grep pipelines with || true so pipefail doesn't abort on a no-match.
1 parent 4d89203 commit 5851fe4

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

scripts/test-stateless-demo-04-process-scoped-state.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ for k in k1 k2 k3 k4 k5 k6 k7 k8; do
5656
done
5757
stats="$("${COMPOSE[@]}" exec -T "$SVC" /usr/local/bin/state-client 127.0.0.1:50051 stats 2>&1 | filter_compose)"
5858
printf '%s\n' "$stats" | sed 's/^/ /'
59-
size=$(printf '%s\n' "$stats" | grep -oE 'cache_size=[0-9]+' | head -1 | cut -d= -f2)
60-
cap=$(printf '%s\n' "$stats" | grep -oE 'cache_capacity=[0-9]+' | head -1 | cut -d= -f2)
61-
evict=$(printf '%s\n' "$stats" | grep -oE 'evictions=[0-9]+' | head -1 | cut -d= -f2)
59+
size_field=$(printf '%s\n' "$stats" | grep -oE 'cache_size=[0-9]+(/[0-9]+)?' | head -1 | cut -d= -f2 || true)
60+
size=${size_field%%/*}
61+
cap=$(printf '%s\n' "$stats" | grep -oE 'cache_capacity=[0-9]+' | head -1 | cut -d= -f2 || true)
62+
# fall back: cache_size=N/M encodes capacity as the denominator
63+
[[ -z "$cap" && "$size_field" == */* ]] && cap=${size_field##*/}
64+
evict=$(printf '%s\n' "$stats" | grep -oE 'evictions=[0-9]+' | head -1 | cut -d= -f2 || true)
6265
if [[ "${size:-}" == "${cap:-x}" && "${evict:-0}" -gt 0 ]]; then
6366
log_ok "cache bounded at $size/$cap with $evict evictions"
6467
else

0 commit comments

Comments
 (0)