use of com.alibaba.graphscope.groot.coordinator.LogRecycler in project GraphScope by alibaba.
the class LogRecyclerTest method testRecycler.
@Test
void testRecycler() throws IOException {
Configs configs = Configs.newBuilder().put(CoordinatorConfig.LOG_RECYCLE_INTERVAL_SECOND.getKey(), "1").build();
SnapshotManager mockSnapshotManager = mock(SnapshotManager.class);
when(mockSnapshotManager.getQueueOffsets()).thenReturn(Arrays.asList(1L, 2L, 3L));
LogService mockLogService = mock(LogService.class);
LogRecycler logRecycler = new LogRecycler(configs, mockLogService, mockSnapshotManager);
CountDownLatch latch1 = new CountDownLatch(1);
CountDownLatch latch2 = new CountDownLatch(1);
CountDownLatch latch3 = new CountDownLatch(1);
doAnswer(invocationOnMock -> {
latch1.countDown();
return null;
}).when(mockLogService).deleteBeforeOffset(0, 1L);
doAnswer(invocationOnMock -> {
latch2.countDown();
return null;
}).when(mockLogService).deleteBeforeOffset(1, 2L);
doAnswer(invocationOnMock -> {
latch3.countDown();
return null;
}).when(mockLogService).deleteBeforeOffset(2, 3L);
logRecycler.start();
assertAll(() -> assertTrue(latch1.await(5L, TimeUnit.SECONDS)), () -> assertTrue(latch2.await(5L, TimeUnit.SECONDS)), () -> assertTrue(latch3.await(5L, TimeUnit.SECONDS)));
logRecycler.stop();
}
Aggregations