use of com.hazelcast.jet.core.TestProcessors.MockPMS in project hazelcast by hazelcast.
the class JobLifecycleMetricsTest method multipleJobsSubmittedAndCompleted.
@Test
public void multipleJobsSubmittedAndCompleted() {
// when
Job job1 = hzInstances[0].getJet().newJob(batchPipeline());
job1.join();
job1.cancel();
// then
assertTrueEventually(() -> assertJobStats(1, 1, 1, 1, 0));
// given
DAG dag = new DAG();
Throwable e = new AssertionError("mock error");
Vertex source = dag.newVertex("source", ListSource.supplier(singletonList(1)));
Vertex process = dag.newVertex("faulty", new MockPMS(() -> new MockPS(() -> new MockP().setProcessError(e), MEMBER_COUNT)));
dag.edge(between(source, process));
// when
Job job2 = hzInstances[0].getJet().newJob(dag);
try {
job2.join();
fail("Expected exception not thrown!");
} catch (Exception ex) {
// ignore
}
// then
assertTrueEventually(() -> assertJobStats(2, 2, 2, 1, 1));
}
use of com.hazelcast.jet.core.TestProcessors.MockPMS in project hazelcast by hazelcast.
the class ExecutionLifecycleTest method when_jobCompletesSuccessfully_then_closeCalled.
@Test
public void when_jobCompletesSuccessfully_then_closeCalled() {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPMS(() -> new MockPS(MockP::new, MEMBER_COUNT))));
// When
Job job = newJob(dag);
job.join();
// Then
assertPClosedWithoutError();
assertPsClosedWithoutError();
assertPmsClosedWithoutError();
assertJobSucceeded(job);
}
use of com.hazelcast.jet.core.TestProcessors.MockPMS 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.MockPMS 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.MockPMS 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);
}
Aggregations