mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 11:31:14 +00:00
[AZ-504] Fix grep | wc -l pipefail crash in PT-08 batch counting
scripts/run-performance-tests.sh:416-417 used `grep -o ... | wc -l` to count `"status":"accepted"` and `"status":"rejected"` markers in the PT-08 batch response. On the happy path (rejected=0) grep -o exits 1, and under `set -o pipefail` + `set -e` (line 16) the pipeline killed the script before reaching any of PT-08's reporting code — reproducing twice in the cycle-3 perf-harness leftover (replay #2 + #3 post-AZ-500). Fix: neutralise grep's no-match exit locally with `|| true` on the grep stage of each pipeline. `grep -o | wc -l` is kept (not swapped for `grep -c`) because the PT-08 response is compact JSON — all items live on one line, so `grep -c` would always return 1 and lose occurrence-count semantics. An 8-line comment explains why grep cannot fail for I/O at this code path (file is curl-written, HTTP 200 gated). AC-1 + AC-2 verified in-place against a standalone harness under `set -e -o pipefail` (compact-JSON, mixed-status, edge-empty cases). AC-3 + AC-4 are Step 15 (Performance Test) obligations by spec design — the leftover deletion (AC-4) is "in the same commit" as the green full perf run. Batch report: _docs/03_implementation/batch_01_cycle5_report.md. Code review: _docs/03_implementation/reviews/batch_01_cycle5_review.md — PASS, no findings. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -413,8 +413,16 @@ else
|
||||
continue
|
||||
fi
|
||||
|
||||
accepted=$(grep -o '"status":"accepted"' "$PERF_TMP_DIR/pt08_resp.json" | wc -l | tr -d ' ')
|
||||
rejected=$(grep -o '"status":"rejected"' "$PERF_TMP_DIR/pt08_resp.json" | wc -l | tr -d ' ')
|
||||
# AZ-504: grep exits 1 on zero matches. Under `set -o pipefail` (line 16)
|
||||
# that kills the assignment and crashes the script on the happy path
|
||||
# (rejected=0). Neutralise the no-match case locally with `|| true` so
|
||||
# the pipeline still produces a count. The response is compact JSON
|
||||
# (one line, all items) so `grep -o | wc -l` is required to count
|
||||
# occurrences — `grep -c` would only count matching lines (=1). The
|
||||
# file is guaranteed-readable here (curl wrote it earlier in this
|
||||
# iteration on the HTTP 200 branch), so grep cannot fail for I/O.
|
||||
accepted=$({ grep -o '"status":"accepted"' "$PERF_TMP_DIR/pt08_resp.json" || true; } | wc -l | tr -d ' ')
|
||||
rejected=$({ grep -o '"status":"rejected"' "$PERF_TMP_DIR/pt08_resp.json" || true; } | wc -l | tr -d ' ')
|
||||
PT08_ACCEPTED=$((PT08_ACCEPTED + accepted))
|
||||
PT08_REJECTED=$((PT08_REJECTED + rejected))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user