use of com.hazelcast.jet.core.TestProcessors.MockPS in project hazelcast by hazelcast.
the class ExecutionLifecycleTest method when_processorInitThrows_then_failJob.
@Test
public void when_processorInitThrows_then_failJob() {
// Given
DAG dag = new DAG();
dag.newVertex("faulty", new MockPMS(() -> new MockPS(() -> new MockP().setInitError(MOCK_ERROR), MEMBER_COUNT)));
// When
Job job = runJobExpectFailure(dag, false);
// Then
assertPClosedWithError();
assertPsClosedWithError();
assertPmsClosedWithError();
assertJobFailed(job, MOCK_ERROR);
}
use of com.hazelcast.jet.core.TestProcessors.MockPS in project hazelcast by hazelcast.
the class ExecutionLifecycleTest method when_processorCloseThrows_then_jobSucceeds.
@Test
public void when_processorCloseThrows_then_jobSucceeds() {
// Given
DAG dag = new DAG();
dag.newVertex("faulty", new MockPMS(() -> new MockPS(() -> new MockP().setCloseError(MOCK_ERROR), MEMBER_COUNT)));
// When
Job job = newJob(dag);
job.join();
// Then
assertPClosedWithoutError();
assertPsClosedWithoutError();
assertPmsClosedWithoutError();
assertJobSucceeded(job);
}
use of com.hazelcast.jet.core.TestProcessors.MockPS in project hazelcast by hazelcast.
the class ExecutionLifecycleTest method when_processorCooperativeCompleteThrows_then_failJob.
@Test
public void when_processorCooperativeCompleteThrows_then_failJob() {
// Given
DAG dag = new DAG();
dag.newVertex("faulty", new MockPMS(() -> new MockPS(() -> new MockP().setCompleteError(MOCK_ERROR), MEMBER_COUNT)));
// When
Job job = runJobExpectFailure(dag, false);
// Then
assertPClosedWithError();
assertPsClosedWithError();
assertPmsClosedWithError();
assertJobFailed(job, MOCK_ERROR);
}
use of com.hazelcast.jet.core.TestProcessors.MockPS in project hazelcast by hazelcast.
the class JobTest method when_namedJobIsRunning_then_newNamedJobFails.
private void when_namedJobIsRunning_then_newNamedJobFails(HazelcastInstance instance) {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT * 2)));
JobConfig config = new JobConfig().setName(randomName());
// When
Job job1 = instance.getJet().newJob(dag, config);
assertTrueEventually(() -> assertEquals(RUNNING, job1.getStatus()));
// Then
assertThatThrownBy(() -> instance.getJet().newJob(dag, config)).isInstanceOf(JobAlreadyExistsException.class);
}
use of com.hazelcast.jet.core.TestProcessors.MockPS in project hazelcast by hazelcast.
the class JobTest method when_jobIsRunning_then_itIsQueriedByName.
private void when_jobIsRunning_then_itIsQueriedByName(HazelcastInstance instance) throws InterruptedException {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
JobConfig config = new JobConfig();
String jobName = randomName();
config.setName(jobName);
// When
Job job = instance().getJet().newJob(dag, config);
assertEquals(jobName, job.getName());
NoOutputSourceP.executionStarted.await();
// Then
Job trackedJob = instance.getJet().getJob(jobName);
assertNotNull(trackedJob);
assertEquals(jobName, trackedJob.getName());
assertEquals(job.getId(), trackedJob.getId());
assertJobStatusEventually(trackedJob, RUNNING);
NoOutputSourceP.proceedLatch.countDown();
}
Aggregations