use of com.hazelcast.jet.core.TestProcessors.MockPS in project hazelcast-jet by hazelcast.
the class ExecutionLifecycleTest method when_processorNonCooperativeCompleteThrows_then_failJob.
@Test
public void when_processorNonCooperativeCompleteThrows_then_failJob() {
// Given
DAG dag = new DAG();
RuntimeException e = new RuntimeException("mock error");
dag.newVertex("faulty", nonCooperativeP(new MockPMS(() -> new MockPS(() -> new MockP().setCompleteError(e), NODE_COUNT))));
// When
Job job = runJobExpectFailure(dag, e);
// Then
assertPClosedWithError(e, false);
assertPsClosedWithError(e);
assertPmsClosedWithError(e);
assertJobFailed(job, e);
}
use of com.hazelcast.jet.core.TestProcessors.MockPS 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.MockPS 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.MockPS 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.MockPS 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