From a450fb4eaecd738be6f08803b2cfc03171720df4 Mon Sep 17 00:00:00 2001 From: Robin Han Date: Tue, 16 Apr 2024 21:05:06 +0800 Subject: [PATCH] fix: fix flaky test Signed-off-by: Robin Han --- .../stream/s3/cache/blockcache/StreamReaderTest.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/s3stream/src/test/java/com/automq/stream/s3/cache/blockcache/StreamReaderTest.java b/s3stream/src/test/java/com/automq/stream/s3/cache/blockcache/StreamReaderTest.java index 9be36fc615..8d41540d77 100644 --- a/s3stream/src/test/java/com/automq/stream/s3/cache/blockcache/StreamReaderTest.java +++ b/s3stream/src/test/java/com/automq/stream/s3/cache/blockcache/StreamReaderTest.java @@ -181,10 +181,12 @@ public void testRead_withReadahead() throws ExecutionException, InterruptedExcep // - load more index // - readahead from offset = 14...22 verify(dataBlockCache, timeout(1000).times(14 + 9 + 8)).getBlock(any(), any()); - assertEquals(34L, streamReader.loadedBlockIndexEndOffset); - assertEquals(14L + 8, streamReader.readahead.nextReadaheadOffset); - assertEquals(14L, streamReader.readahead.readaheadMarkOffset); - assertEquals(1024L * 1024 * 2, streamReader.readahead.nextReadaheadSize); + eventLoops[0].submit(() -> { + assertEquals(34L, streamReader.loadedBlockIndexEndOffset); + assertEquals(14L + 8, streamReader.readahead.nextReadaheadOffset); + assertEquals(14L, streamReader.readahead.readaheadMarkOffset); + assertEquals(1024L * 1024 * 2, streamReader.readahead.nextReadaheadSize); + }).get(); when(objectManager.isObjectExist(anyLong())).thenReturn(false); @@ -207,7 +209,6 @@ public void testRead_withReadahead() throws ExecutionException, InterruptedExcep } }).when(objectManager).isObjectExist(anyLong()); eventLoops[0].submit(() -> readCf.set(streamReader.read(14L, 15L, Integer.MAX_VALUE))).get(); - rst = readCf.get().get(1, TimeUnit.SECONDS); }