use of com.alibaba.graphscope.groot.ingestor.IngestService 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();
}
use of com.alibaba.graphscope.groot.ingestor.IngestService in project GraphScope by alibaba.
the class IngestorRpcTest method testIngestorWriteService.
@Test
void testIngestorWriteService() {
IngestService ingestService = mock(IngestService.class);
IngestorWriteService ingestorWriteService = new IngestorWriteService(ingestService);
WriteIngestorRequest req = WriteIngestorRequest.newBuilder().setQueueId(2).setRequestId("test_req").setOperationBatch(OperationBatch.newBuilder().build().toProto()).build();
doAnswer(invocation -> {
IngestCallback callback = invocation.getArgument(3);
callback.onSuccess(10L);
return null;
}).when(ingestService).ingestBatch(eq("test_req"), eq(2), eq(OperationBatch.newBuilder().build()), any());
StreamObserver<WriteIngestorResponse> observer = mock(StreamObserver.class);
ingestorWriteService.writeIngestor(req, observer);
verify(observer).onNext(WriteIngestorResponse.newBuilder().setSnapshotId(10L).build());
verify(observer).onCompleted();
}
use of com.alibaba.graphscope.groot.ingestor.IngestService in project GraphScope by alibaba.
the class IngestorRpcTest method testIngestorSnapshotService.
@Test
void testIngestorSnapshotService() {
IngestService ingestService = mock(IngestService.class);
IngestorSnapshotService ingestorSnapshotService = new IngestorSnapshotService(ingestService);
AdvanceIngestSnapshotIdRequest req = AdvanceIngestSnapshotIdRequest.newBuilder().setSnapshotId(10L).build();
StreamObserver<AdvanceIngestSnapshotIdResponse> streamObserver = mock(StreamObserver.class);
doAnswer(invocation -> {
CompletionCallback<Long> callback = invocation.getArgument(1);
callback.onCompleted(9L);
return null;
}).when(ingestService).advanceIngestSnapshotId(anyLong(), any());
ingestorSnapshotService.advanceIngestSnapshotId(req, streamObserver);
verify(streamObserver).onNext(AdvanceIngestSnapshotIdResponse.newBuilder().setPreviousSnapshotId(9L).build());
verify(streamObserver).onCompleted();
}
Aggregations