Skip to content

Commit 5ae7149

Browse files
bluestreak01claude
andcommitted
Switch durable-ack fuzz to QuestDB Rnd + TestUtils.generateRandom
Use the project's Rnd and the generateRandom helper instead of a raw java.util.Random. generateRandom logs the (s0, s1) seed pair to stdout, which is the project-standard repro recipe -- a flake in CI now leaves the exact seeds in the test output, and operators reproduce by passing them back into TestUtils.generateRandom(null, s0, s1). The AssertionError on fuzz failure also includes both seeds, so the repro recipe is co-located with the failure stack rather than buried in surrounding stdout that may or may not survive CI log retention. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 21d885b commit 5ae7149

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

core/src/test/java/io/questdb/client/test/cutlass/qwp/client/sf/cursor/CursorWebSocketSendLoopDurableAckFuzzTest.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import io.questdb.client.cutlass.qwp.client.sf.cursor.CursorWebSocketSendLoop;
3030
import io.questdb.client.std.Files;
3131
import io.questdb.client.std.MemoryTag;
32+
import io.questdb.client.std.Rnd;
3233
import io.questdb.client.std.Unsafe;
3334
import io.questdb.client.test.tools.TestUtils;
3435
import org.junit.After;
@@ -42,7 +43,6 @@
4243
import java.nio.file.Paths;
4344
import java.util.HashMap;
4445
import java.util.Map;
45-
import java.util.Random;
4646

4747
/**
4848
* Randomised stress test for the durable-ack-driven trim path. Generates a
@@ -56,7 +56,6 @@
5656
*/
5757
public class CursorWebSocketSendLoopDurableAckFuzzTest {
5858

59-
private static final long DEFAULT_SEED = -1L;
6059
private static final int ITERATIONS = 500;
6160
private static final int MAX_FRAMES = 64;
6261
private static final String[] TABLE_POOL = {"trades", "orders", "fills", "positions"};
@@ -92,15 +91,21 @@ public void tearDown() {
9291
}
9392

9493
@Test
95-
public void testFuzzInvariantHolds() throws Exception {
96-
long seed = DEFAULT_SEED == -1L ? System.nanoTime() : DEFAULT_SEED;
97-
Random rnd = new Random(seed);
94+
public void testFuzzInvariantHolds() {
95+
// Capture both seeds so a fuzz failure prints a reproducer the
96+
// operator can plug straight back into TestUtils.generateRandom(
97+
// null, s0, s1). generateRandom also prints them on its own, but
98+
// including them in the AssertionError message keeps the repro
99+
// recipe co-located with the failure in CI logs.
100+
long s0 = System.nanoTime();
101+
long s1 = System.currentTimeMillis();
102+
Rnd rnd = TestUtils.generateRandom(null, s0, s1);
98103
try {
99104
for (int iter = 0; iter < ITERATIONS; iter++) {
100105
runOneIteration(rnd, iter);
101106
}
102107
} catch (Throwable t) {
103-
throw new AssertionError("fuzz failure with seed=" + seed, t);
108+
throw new AssertionError("fuzz failure with seeds=" + s0 + "L," + s1 + "L", t);
104109
}
105110
}
106111

@@ -167,7 +172,7 @@ private static void deliver(CursorWebSocketSendLoop loop, long packed) throws Ex
167172
}
168173
}
169174

170-
private static void runOneIteration(Random rnd, int iter) throws Exception {
175+
private static void runOneIteration(Rnd rnd, int iter) throws Exception {
171176
// Pre-build: pick frame count, per-batch tables. Track expected
172177
// (table, seqTxn) so the fuzz oracle can compute the contiguous
173178
// durable prefix at any point.

0 commit comments

Comments
 (0)