use of com.hazelcast.jet.core.TestProcessors.StuckProcessor in project hazelcast-jet by hazelcast.
the class ExecutionLifecycleTest method when_jobCancelled_then_psCloseNotCalledBeforeTaskletsDone.
@Test
public void when_jobCancelled_then_psCloseNotCalledBeforeTaskletsDone() {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(() -> new StuckProcessor(10_000), NODE_COUNT)));
// When
Job job = instance.newJob(dag);
assertOpenEventually(StuckProcessor.executionStarted);
// Then
job.cancel();
assertTrueEventually(() -> assertEquals(JobStatus.COMPLETING, job.getStatus()), 3);
assertTrueFiveSeconds(() -> {
assertEquals(JobStatus.COMPLETING, job.getStatus());
assertEquals("PS.close called before execution finished", 0, MockPS.closeCount.get());
});
StuckProcessor.proceedLatch.countDown();
expectedException.expect(CancellationException.class);
job.join();
assertEquals("PS.close not called after execution finished", NODE_COUNT, MockPS.closeCount.get());
}
use of com.hazelcast.jet.core.TestProcessors.StuckProcessor in project hazelcast-jet by hazelcast.
the class JobTest method when_jobIsCompleted_then_trackedJobCanQueryJobResult.
@Test
public void when_jobIsCompleted_then_trackedJobCanQueryJobResult() throws InterruptedException {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT)));
// When
instance1.newJob(dag);
StuckProcessor.executionStarted.await();
Collection<Job> trackedJobs = instance2.getJobs();
assertEquals(1, trackedJobs.size());
Job trackedJob = trackedJobs.iterator().next();
StuckProcessor.proceedLatch.countDown();
// Then
trackedJob.join();
assertEquals(COMPLETED, trackedJob.getStatus());
}
use of com.hazelcast.jet.core.TestProcessors.StuckProcessor in project hazelcast-jet by hazelcast.
the class JobTest method testGetJobByIdWhenJobIsRunning.
private void testGetJobByIdWhenJobIsRunning(JetInstance instance) throws InterruptedException {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT)));
// When
Job job = instance1.newJob(dag);
StuckProcessor.executionStarted.await();
// Then
Job trackedJob = instance.getJob(job.getId());
assertNotNull(trackedJob);
assertEquals(job.getId(), trackedJob.getId());
assertTrueEventually(() -> assertEquals(RUNNING, trackedJob.getStatus()));
StuckProcessor.proceedLatch.countDown();
}
use of com.hazelcast.jet.core.TestProcessors.StuckProcessor in project hazelcast-jet by hazelcast.
the class JobTest method when_jobIsSubmitted_then_trackedJobCanQueryJobStatus.
@Test
public void when_jobIsSubmitted_then_trackedJobCanQueryJobStatus() throws InterruptedException {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT)));
// When
Job submittedJob = instance1.newJob(dag);
StuckProcessor.executionStarted.await();
Collection<Job> trackedJobs = instance2.getJobs();
assertEquals(1, trackedJobs.size());
Job trackedJob = trackedJobs.iterator().next();
// Then
assertTrueEventually(() -> assertEquals(RUNNING, trackedJob.getStatus()));
submittedJob.cancel();
joinAndExpectCancellation(submittedJob);
}
use of com.hazelcast.jet.core.TestProcessors.StuckProcessor in project hazelcast-jet by hazelcast.
the class JobTest method testGetJobByNameWhenJobIsRunning.
private void testGetJobByNameWhenJobIsRunning(JetInstance instance) throws InterruptedException {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT)));
JobConfig config = new JobConfig();
String jobName = "job1";
config.setName(jobName);
// When
Job job = instance1.newJob(dag, config);
assertEquals(jobName, job.getName());
StuckProcessor.executionStarted.await();
// Then
Job trackedJob = instance.getJob(jobName);
assertNotNull(trackedJob);
assertEquals(jobName, trackedJob.getName());
assertEquals(job.getId(), trackedJob.getId());
assertTrueEventually(() -> assertEquals(RUNNING, trackedJob.getStatus()));
StuckProcessor.proceedLatch.countDown();
}
Aggregations