Search in sources :

Example 6 with MockPMS

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));
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) MockPMS(com.hazelcast.jet.core.TestProcessors.MockPMS) MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) MockP(com.hazelcast.jet.core.TestProcessors.MockP) DAG(com.hazelcast.jet.core.DAG) Job(com.hazelcast.jet.Job) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with MockPMS

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);
}
Also used : MockPMS(com.hazelcast.jet.core.TestProcessors.MockPMS) MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) Job(com.hazelcast.jet.Job) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with MockPMS

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);
}
Also used : MockPMS(com.hazelcast.jet.core.TestProcessors.MockPMS) MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) MockP(com.hazelcast.jet.core.TestProcessors.MockP) Job(com.hazelcast.jet.Job) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with MockPMS

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);
}
Also used : MockPMS(com.hazelcast.jet.core.TestProcessors.MockPMS) MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) MockP(com.hazelcast.jet.core.TestProcessors.MockP) Job(com.hazelcast.jet.Job) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 10 with MockPMS

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);
}
Also used : MockPMS(com.hazelcast.jet.core.TestProcessors.MockPMS) MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) MockP(com.hazelcast.jet.core.TestProcessors.MockP) Job(com.hazelcast.jet.Job) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

MockPMS (com.hazelcast.jet.core.TestProcessors.MockPMS)31 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)31 Job (com.hazelcast.jet.Job)30 Test (org.junit.Test)30 MockP (com.hazelcast.jet.core.TestProcessors.MockP)26 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)17 QuickTest (com.hazelcast.test.annotation.QuickTest)17 NoOutputSourceP (com.hazelcast.jet.core.TestProcessors.NoOutputSourceP)2 CancellationException (java.util.concurrent.CancellationException)2 Config (com.hazelcast.config.Config)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 DAG (com.hazelcast.jet.core.DAG)1 Vertex (com.hazelcast.jet.core.Vertex)1 Before (org.junit.Before)1