diff --git a/packages/mosaic/framework/tools/wake/test-wake-store-ack.sh b/packages/mosaic/framework/tools/wake/test-wake-store-ack.sh index eceecc7e..a26f233c 100755 --- a/packages/mosaic/framework/tools/wake/test-wake-store-ack.sh +++ b/packages/mosaic/framework/tools/wake/test-wake-store-ack.sh @@ -247,11 +247,19 @@ EOF done # Background sync deliberately SLOW: proves the ack does not wait for it. export WAKE_ACK_SYNC_CMD="sleep 3; touch '$WAKE_STATE_HOME/SYNC_DONE'" - start="$(date +%s)" + # Sub-second timing (#918): `date +%s` is SECOND-granularity, so a + # legitimately fast (sub-second) ack that straddles a wall-clock second + # boundary can misreport elapsed=2s and flake under CI load (observed on + # Woodpecker pipeline 2057; 20/20 passes locally elsewhere). Use + # `date +%s.%N` and compare in milliseconds via awk (bash `[ ]` can't do + # float/ms math) against a threshold comfortably below the 3s background + # sync — proving the ack did NOT wait on it — while tolerating a + # legitimate sub-second-to-~1s ack across a boundary. + start="$(date +%s.%N)" out="$(PATH="$bin:$PATH" "$ACK" consumed --upto 1 --wake-id WID-1)" - end="$(date +%s)" - elapsed=$((end - start)) - [ "$elapsed" -lt 2 ] || fail_msg "T7: ack path blocked ${elapsed}s — must return without waiting on the background sync" + end="$(date +%s.%N)" + elapsed_ms="$(awk -v s="$start" -v e="$end" 'BEGIN { printf "%d", (e - s) * 1000 }')" + [ "$elapsed_ms" -lt 1500 ] || fail_msg "T7: ack path blocked ${elapsed_ms}ms — must return without waiting on the background sync" echo "$out" | grep -q 'CONSUMED 1' || fail_msg "T7: CONSUMED not reported [$out]" # Local write is durable IMMEDIATELY (no network needed to record the ack). STATE_DIR="$WAKE_STATE_HOME/default"