From 4a7ac58bd8ee2fda1fb7e50f2ecebf0008f86c38 Mon Sep 17 00:00:00 2001 From: Sandy Chen Date: Fri, 22 May 2026 18:48:50 +0900 Subject: [PATCH] fix(integration): repair TestExpandedPostingsCacheFuzz latent bugs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TestExpandedPostingsCacheFuzz had two independent defects that together neutered the test: 1. The query-generation loop at integration/query_fuzz_test.go:550-557 was inverted: `break` fired the moment isValidQuery returned true, exiting the outer `for i` loop, and only *invalid* expressions ever reached the append. The queries/matchers slices ended up holding at most testRun invalid exprs (or empty if the first draw was valid). Every downstream c1.Query / c1.QueryRange call then short-circuited with the same error on both clients, so cmp.Equal(err1, err2) trivially held and nothing was actually compared. 2. The Series diff branch at integration/query_fuzz_test.go:657 read `cmp.Equal(tc.sres1, tc.sres1, ...)` — self-comparison — so the Series API divergence check was dead code. Net effect: the test had been a no-op for divergences. Issue #7545 captures the empirical census. Fix: wrap the WalkRangeQuery call in a nested `for { ... }` that re-draws until isValidQuery is satisfied, mirroring the sibling fuzz tests in this file, and change `tc.sres1, tc.sres1` to `tc.sres1, tc.sres2`. No production code touched; enabledAggrs is already wired in. Two follow-ups worth flagging honestly: wall-clock will grow substantially (the previously-skipped ~9k HTTP round-trips now actually run), and any genuine v1.18.0-vs-HEAD divergence in the expanded-postings-cache code path will now surface as a real failure for the first time, to be triaged as a real bug rather than a regression from this PR. Fixes #7545 Co-Authored-By: Claude Opus 4.7 (1M context) Signed-off-by: Sandy Chen --- integration/query_fuzz_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/integration/query_fuzz_test.go b/integration/query_fuzz_test.go index f735bd91d5..242d03786e 100644 --- a/integration/query_fuzz_test.go +++ b/integration/query_fuzz_test.go @@ -550,9 +550,12 @@ func TestExpandedPostingsCacheFuzz(t *testing.T) { queries := make([]string, 0, testRun) matchers := make([]string, 0, testRun) for i := 0; i < testRun; i++ { - expr := ps.WalkRangeQuery() - if isValidQuery(expr, true) { - break + var expr parser.Expr + for { + expr = ps.WalkRangeQuery() + if isValidQuery(expr, true) { + break + } } queries = append(queries, expr.Pretty(0)) matchers = append(matchers, storepb.PromMatchersToString( @@ -651,7 +654,7 @@ func TestExpandedPostingsCacheFuzz(t *testing.T) { } else if !cmp.Equal(tc.res1, tc.res2, comparer) { t.Logf("case %d results mismatch.\n%s: %s\nres1: %s\nres2: %s\n", i, tc.qt, tc.query, tc.res1.String(), tc.res2.String()) failures++ - } else if !cmp.Equal(tc.sres1, tc.sres1, labelSetsComparer) { + } else if !cmp.Equal(tc.sres1, tc.sres2, labelSetsComparer) { t.Logf("case %d results mismatch.\n%s: %s\nsres1: %s\nsres2: %s\n", i, tc.qt, tc.query, tc.sres1, tc.sres2) failures++ }