use of io.crate.jobs.DummySubContext in project crate by crate.
the class NodeDisconnectJobMonitorServiceTest method testOnParticipatingNodeDisconnectedKillsJob.
@Test
public void testOnParticipatingNodeDisconnectedKillsJob() throws Exception {
JobContextService jobContextService = jobContextService();
DiscoveryNode coordinator_node = new DiscoveryNode("coordinator_node_id", DummyTransportAddress.INSTANCE, Version.CURRENT);
DiscoveryNode data_node = new DiscoveryNode("data_node_id", DummyTransportAddress.INSTANCE, Version.CURRENT);
DiscoveryNodes discoveryNodes = DiscoveryNodes.builder().localNodeId("coordinator_node_id").put(coordinator_node).put(data_node).build();
JobExecutionContext.Builder builder = jobContextService.newBuilder(UUID.randomUUID(), coordinator_node.getId(), Arrays.asList(coordinator_node.getId(), data_node.getId()));
builder.addSubContext(new DummySubContext());
jobContextService.createContext(builder);
TransportKillJobsNodeAction killAction = mock(TransportKillJobsNodeAction.class);
NodeDisconnectJobMonitorService monitorService = new NodeDisconnectJobMonitorService(Settings.EMPTY, mock(ThreadPool.class), jobContextService, mock(TransportService.class), killAction);
monitorService.onNodeDisconnected(discoveryNodes.get("data_node_id"));
verify(killAction, times(1)).broadcast(any(KillJobsRequest.class), any(ActionListener.class), eq(Arrays.asList(discoveryNodes.get("data_node_id").getId())));
}
use of io.crate.jobs.DummySubContext in project crate by crate.
the class NodeDisconnectJobMonitorServiceTest method testOnNodeDisconnectedKillsJobOriginatingFromThatNode.
@Test
public void testOnNodeDisconnectedKillsJobOriginatingFromThatNode() throws Exception {
JobContextService jobContextService = jobContextService();
JobExecutionContext.Builder builder = jobContextService.newBuilder(UUID.randomUUID());
builder.addSubContext(new DummySubContext());
JobExecutionContext context = jobContextService.createContext(builder);
ThreadPool threadPool = mock(ThreadPool.class);
when(threadPool.schedule(any(TimeValue.class), anyString(), any(Runnable.class))).thenAnswer((Answer<Object>) invocation -> {
((Runnable) invocation.getArguments()[2]).run();
return null;
});
NodeDisconnectJobMonitorService monitorService = new NodeDisconnectJobMonitorService(Settings.EMPTY, threadPool, jobContextService, mock(TransportService.class), mock(TransportKillJobsNodeAction.class));
monitorService.onNodeDisconnected(new DiscoveryNode("noop_id", DummyTransportAddress.INSTANCE, Version.CURRENT));
expectedException.expect(ContextMissingException.class);
jobContextService.getContext(context.jobId());
}
Aggregations