use of com.alibaba.graphscope.groot.ingestor.IngestProgressFetcher in project GraphScope by alibaba.
the class IngestServiceTest method testIngestService.
@Test
void testIngestService() {
Configs configs = Configs.newBuilder().put(CommonConfig.NODE_IDX.getKey(), "0").put(CommonConfig.STORE_NODE_COUNT.getKey(), "1").put(IngestorConfig.INGESTOR_CHECK_PROCESSOR_INTERVAL_MS.getKey(), "100").build();
MockDiscovery mockDiscovery = new MockDiscovery();
MetaService mockMetaService = mock(MetaService.class);
when(mockMetaService.getQueueIdsForIngestor(0)).thenReturn(Arrays.asList(0));
LogService mockLogService = mock(LogService.class);
IngestProgressFetcher mockIngestProgressFetcher = mock(IngestProgressFetcher.class);
when(mockIngestProgressFetcher.getTailOffsets(Arrays.asList(0))).thenReturn(Arrays.asList(50L));
StoreWriter mockStoreWriter = mock(StoreWriter.class);
IngestService spyIngestService = spy(new IngestService(configs, mockDiscovery, mockMetaService, mockLogService, mockIngestProgressFetcher, mockStoreWriter, new MetricsCollector(configs)));
IngestProcessor mockIngestProcessor = mock(IngestProcessor.class);
doReturn(mockIngestProcessor).when(spyIngestService).makeIngestProcessor(any(), any(), any(), eq(0), any(), any());
spyIngestService.start();
verify(mockIngestProcessor, never()).start();
mockDiscovery.addNode(RoleType.STORE, Collections.singletonMap(0, null));
verify(mockIngestProcessor, timeout(5000L)).setTailOffset(50L);
verify(mockIngestProcessor, timeout(5000L)).start();
spyIngestService.advanceIngestSnapshotId(5L, null);
verify(mockIngestProcessor).ingestBatch(eq("marker"), eq(IngestService.MARKER_BATCH), any());
mockDiscovery.removeNode(RoleType.STORE, Collections.singletonMap(0, null));
verify(mockIngestProcessor, timeout(5000L).times(2)).stop();
spyIngestService.stop();
}
Aggregations