Skip to content

Commit dc61471

Browse files
committed
Time only close() in WasUpAllAlong drain test
testAsyncCloseDrainSucceedsWhenServerWasUpAllAlong timed the whole try (Sender = fromConfig(...)) { write; flush; } close block against a 2500ms budget, but the assertion budgets close()'s drain latency, not sender construction. Iteration 0 is the first store-and-forward async sender in the JVM, so fromConfig pays a one-time cold-start cost (class loading, JIT, sf buffer mmap). On a loaded CI runner that cold start reached ~3.26s and tripped the assertion, even though close() itself took ~12ms. Move t0 to wrap only sender.close(), matching the sibling test testAsyncCloseDrainSucceedsWhenServerStartsDuringDrain. close() is idempotent, so the try-with-resources auto-close is a no-op. Measured close() latency stays in the single-digit milliseconds across all 20 iterations, well within the 2500ms budget.
1 parent a02732c commit dc61471

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

core/src/test/java/io/questdb/client/test/cutlass/qwp/client/CloseDrainTest.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,20 @@ public void testAsyncCloseDrainSucceedsWhenServerWasUpAllAlong() throws Exceptio
358358
+ ";reconnect_initial_backoff_millis=20"
359359
+ ";reconnect_max_backoff_millis=100"
360360
+ ";close_flush_timeout_millis=3000;";
361-
long t0 = System.nanoTime();
362361
try (Sender sender = Sender.fromConfig(cfg)) {
363362
sender.table("foo").longColumn("v", i).atNow();
364363
sender.flush();
364+
// Time only close(): the 2500ms budget covers close()'s
365+
// drain latency. Building the first store-and-forward
366+
// sender carries a one-time cold-start cost (class
367+
// loading, JIT, sf buffer mmap) that belongs to
368+
// construction, not to close().
369+
long t0 = System.nanoTime();
370+
sender.close();
371+
long elapsedMs = (System.nanoTime() - t0) / 1_000_000;
372+
Assert.assertTrue("iteration " + i + " close() took " + elapsedMs + "ms",
373+
elapsedMs < 2500);
365374
}
366-
long elapsedMs = (System.nanoTime() - t0) / 1_000_000;
367-
Assert.assertTrue("iteration " + i + " close() took " + elapsedMs + "ms",
368-
elapsedMs < 2500);
369375
}
370376
}
371377
}

0 commit comments

Comments
 (0)