Search in sources :

Example 11 with MockPMS

use of com.hazelcast.jet.core.TestProcessors.MockPMS in project hazelcast by hazelcast.

the class ExecutionLifecycleTest method when_pmsCloseThrows_then_jobSucceeds.

@Test
public void when_pmsCloseThrows_then_jobSucceeds() {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPMS(() -> new MockPS(MockP::new, MEMBER_COUNT)).setCloseError(MOCK_ERROR)));
    // 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 12 with MockPMS

use of com.hazelcast.jet.core.TestProcessors.MockPMS in project hazelcast by hazelcast.

the class ExecutionLifecycleTest method when_processorNonCooperativeCompleteThrows_then_failJob.

@Test
public void when_processorNonCooperativeCompleteThrows_then_failJob() {
    // Given
    DAG dag = new DAG();
    dag.newVertex("faulty", new MockPMS(() -> new MockPS(() -> new MockP().nonCooperative().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)

Example 13 with MockPMS

use of com.hazelcast.jet.core.TestProcessors.MockPMS in project hazelcast by hazelcast.

the class ExecutionLifecycleTest method when_oneOfTwoJobsFails_then_theOtherContinues.

@Test
public void when_oneOfTwoJobsFails_then_theOtherContinues() throws Exception {
    // Given
    DAG dagFaulty = new DAG().vertex(new Vertex("faulty", new MockPMS(() -> new MockPS(() -> new MockP().setCompleteError(MOCK_ERROR), MEMBER_COUNT))));
    DAG dagGood = new DAG();
    dagGood.newVertex("good", () -> new NoOutputSourceP());
    // When
    Job jobGood = newJob(dagGood);
    NoOutputSourceP.executionStarted.await();
    runJobExpectFailure(dagFaulty, false);
    // Then
    assertTrueAllTheTime(() -> assertFalse(jobGood.getFuture().isDone()), 2);
    NoOutputSourceP.proceedLatch.countDown();
    jobGood.join();
}
Also used : MockPMS(com.hazelcast.jet.core.TestProcessors.MockPMS) MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) MockP(com.hazelcast.jet.core.TestProcessors.MockP) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Job(com.hazelcast.jet.Job) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 14 with MockPMS

use of com.hazelcast.jet.core.TestProcessors.MockPMS in project hazelcast by hazelcast.

the class ExecutionLifecycleTest method when_pmsGetThrows_then_jobFails.

@Test
public void when_pmsGetThrows_then_jobFails() {
    // Given
    DAG dag = new DAG().vertex(new Vertex("faulty", new MockPMS(() -> new MockPS(MockP::new, MEMBER_COUNT)).setGetError(MOCK_ERROR)));
    // When
    Job job = runJobExpectFailure(dag, false);
    // Then
    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 15 with MockPMS

use of com.hazelcast.jet.core.TestProcessors.MockPMS in project hazelcast by hazelcast.

the class ExecutionLifecycleTest method when_processorSaveToSnapshotThrows_then_failJob.

@Test
public void when_processorSaveToSnapshotThrows_then_failJob() {
    // Given
    DAG dag = new DAG();
    dag.newVertex("faulty", new MockPMS(() -> new MockPS(() -> new MockP().nonCooperative().streaming().setSaveToSnapshotError(MOCK_ERROR), MEMBER_COUNT)));
    // When
    Job job = runJobExpectFailure(dag, true);
    assertTrue("saveToSnapshot not called", MockP.saveToSnapshotCalled);
    // 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