Search in sources :

Example 1 with IngestProgressFetcher

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();
}
Also used : MetricsCollector(com.alibaba.graphscope.groot.metrics.MetricsCollector) IngestService(com.alibaba.graphscope.groot.ingestor.IngestService) MetaService(com.alibaba.graphscope.groot.meta.MetaService) StoreWriter(com.alibaba.graphscope.groot.ingestor.StoreWriter) Configs(com.alibaba.maxgraph.common.config.Configs) IngestProgressFetcher(com.alibaba.graphscope.groot.ingestor.IngestProgressFetcher) LogService(com.alibaba.graphscope.groot.wal.LogService) IngestProcessor(com.alibaba.graphscope.groot.ingestor.IngestProcessor) Test(org.junit.jupiter.api.Test)

Aggregations

IngestProcessor (com.alibaba.graphscope.groot.ingestor.IngestProcessor)1 IngestProgressFetcher (com.alibaba.graphscope.groot.ingestor.IngestProgressFetcher)1 IngestService (com.alibaba.graphscope.groot.ingestor.IngestService)1 StoreWriter (com.alibaba.graphscope.groot.ingestor.StoreWriter)1 MetaService (com.alibaba.graphscope.groot.meta.MetaService)1 MetricsCollector (com.alibaba.graphscope.groot.metrics.MetricsCollector)1 LogService (com.alibaba.graphscope.groot.wal.LogService)1 Configs (com.alibaba.maxgraph.common.config.Configs)1 Test (org.junit.jupiter.api.Test)1