Skip to content

Commit d4d5d7d

Browse files
committed
feat: add script to check flakiness of pgjson explain.slt test
1 parent 553efea commit d4d5d7d

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env bash
2+
# check_flaky_pgjson_test.sh
3+
#
4+
# Runs the pgjson explain.slt test multiple times to determine whether
5+
# the failure at line 642 is flaky (non-deterministic) or consistent.
6+
#
7+
# Usage:
8+
# ./ci/scripts/check_flaky_pgjson_test.sh [ITERATIONS]
9+
#
10+
# Default: 10 iterations
11+
12+
set -euo pipefail
13+
14+
ITERATIONS="${1:-10}"
15+
PASS=0
16+
FAIL=0
17+
RESULTS=()
18+
19+
# Locate workspace root (directory containing Cargo.toml with [workspace])
20+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
21+
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
22+
23+
echo "=== Flakiness check for: explain format pgjson select * from values (1) ==="
24+
echo " File : datafusion/sqllogictest/test_files/explain.slt (line 642)"
25+
echo " Iterations: $ITERATIONS"
26+
echo ""
27+
28+
for i in $(seq 1 "$ITERATIONS"); do
29+
# Run only the explain sqllogictest file.
30+
# The -- explain argument matches files whose path contains "explain".
31+
if cargo test \
32+
--quiet \
33+
--manifest-path "$REPO_ROOT/Cargo.toml" \
34+
-p datafusion-sqllogictest \
35+
--test sqllogictests \
36+
-- explain \
37+
2>&1 | grep -q "test result: ok"; then
38+
STATUS="PASS"
39+
PASS=$((PASS + 1))
40+
else
41+
STATUS="FAIL"
42+
FAIL=$((FAIL + 1))
43+
fi
44+
45+
RESULTS+=(" Run $i: $STATUS")
46+
echo " Run $i: $STATUS"
47+
done
48+
49+
echo ""
50+
echo "=== Results ==="
51+
echo " Passed : $PASS / $ITERATIONS"
52+
echo " Failed : $FAIL / $ITERATIONS"
53+
echo ""
54+
55+
if [[ $PASS -gt 0 && $FAIL -gt 0 ]]; then
56+
echo "VERDICT: FLAKY — test result was non-deterministic ($PASS pass, $FAIL fail)"
57+
exit 0
58+
elif [[ $FAIL -eq "$ITERATIONS" ]]; then
59+
echo "VERDICT: CONSISTENTLY FAILING — not flaky, this is a deterministic bug"
60+
echo ""
61+
echo "Likely cause: serde_json is compiled without the 'preserve_order' feature,"
62+
echo "so JSON object keys are sorted alphabetically (BTreeMap) instead of"
63+
echo "preserving insertion order (IndexMap). The test expects insertion order:"
64+
echo " Node Type → Values → Plans → Output"
65+
echo "but always gets alphabetical order:"
66+
echo " Node Type → Output → Plans → Values"
67+
exit 1
68+
else
69+
echo "VERDICT: CONSISTENTLY PASSING — test is healthy"
70+
exit 0
71+
fi

0 commit comments

Comments
 (0)