From e489c727059bb657e1581cd2c66fa1558ca74267 Mon Sep 17 00:00:00 2001 From: slayerjain Date: Tue, 28 Apr 2026 00:12:21 +0530 Subject: [PATCH] fix(http-postgres): use deterministic company names to stop record/replay flake The http-postgres CI pipeline in keploy/integrations intermittently fails on test-4 / test-21 (the POST /companies inserts) with the postgres-v3 "transactional: no invocation matched" / bindShape ["len=16/ascii"] signature. RCA: this script generated random 8-10 char alpha names head -c 8 /dev/urandom | base64 | tr -dc 'a-zA-Z' | head -c 10 so each run produced different bind values for the same SQL, and the postgres-v3 replayer's strict bind-value matcher missed every recorded candidate. The shape-equal fallback (KEPLOY_PG_V3_BINDSHAPE_FALLBACK=1) also missed because the random name length itself varied (the tr -dc step can drop digits, leaving 8 to 10 ASCII chars). Fix: replace the random generator with a deterministic per-iteration counter (Company_${i}). The 10 inserts stay unique within a single run and record/replay agree byte-for-byte on the bind payload. Failing pipelines observed: keploy/integrations 711, 713, 717, 722 (http-postgres workflow, run-build-replay-build leg). Signed-off-by: slayerjain --- http-postgres/test.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/http-postgres/test.sh b/http-postgres/test.sh index c0b77f0b..351df0fb 100755 --- a/http-postgres/test.sh +++ b/http-postgres/test.sh @@ -3,10 +3,15 @@ set -euo pipefail BASE_URL="http://localhost:8080" -# Generate random company names -random_name() { - head -c 8 /dev/urandom | base64 | tr -dc 'a-zA-Z' | head -c 10 -} +# Deterministic per-iteration company names. Previously this used a random +# generator (head -c 8 /dev/urandom | base64 | tr -dc 'a-zA-Z' | head -c 10) +# producing names like "Company_<8-10 random alphas>_", which differ +# between record and replay runs of the Keploy http-postgres CI pipeline. +# The postgres-v3 replayer matches mocks by bind value, so divergent random +# names triggered intermittent "no invocation matched" errors on test-4 / +# test-21 (the POST /companies inserts). A deterministic counter keeps +# inserts unique within a single run while guaranteeing record/replay agree +# byte-for-byte on the bind payload. echo "=== Rapid-fire API test (25+ calls) ===" @@ -14,7 +19,7 @@ echo "=== Rapid-fire API test (25+ calls) ===" echo -e "\n--- Creating 10 unique companies (parallel) ---" pids=() for i in $(seq 1 10); do - name="Company_$(random_name)_$i" + name="Company_${i}" curl -s -w " HTTP %{http_code}\n" -X POST "$BASE_URL/companies" \ -H 'Content-Type: application/json' \ -d "{\"name\": \"$name\"}" &