Search in sources :

Example 21 with MockPMS

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

the class ExecutionLifecycleTest method when_executionCancelled_then_jobCompletedWithCancellationException.

@Test
public void when_executionCancelled_then_jobCompletedWithCancellationException() throws Exception {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPMS(() -> new MockPS(NoOutputSourceP::new, MEMBER_COUNT))));
    // When
    Job job = newJob(dag);
    NoOutputSourceP.executionStarted.await();
    cancelAndJoin(job);
    assertTrueEventually(() -> {
        assertJobFailed(job, new CancellationException());
        assertPsClosedWithError();
        assertPmsClosedWithError();
    });
}
Also used : MockPMS(com.hazelcast.jet.core.TestProcessors.MockPMS) MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) CancellationException(java.util.concurrent.CancellationException) Job(com.hazelcast.jet.Job) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 22 with MockPMS

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

the class ExecutionLifecycleTest method when_processorOnSnapshotCompleteThrows_then_failJob.

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

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

the class ClusterStateChangeTest method before.

@Before
public void before() {
    TestProcessors.reset(TOTAL_PARALLELISM);
    Config config = smallInstanceConfig();
    config.getJetConfig().setCooperativeThreadCount(LOCAL_PARALLELISM);
    members = createHazelcastInstances(config, NODE_COUNT);
    assertTrueEventually(() -> {
        for (HazelcastInstance instance : members) {
            assertClusterSizeEventually(NODE_COUNT, instance);
        }
    });
    for (HazelcastInstance member : members) {
        if (!getNodeEngineImpl(member).getClusterService().isMaster()) {
            hz = member;
            break;
        }
    }
    cluster = hz.getCluster();
    dag = new DAG().vertex(new Vertex("test", new MockPMS(() -> new MockPS(NoOutputSourceP::new, NODE_COUNT))));
}
Also used : MockPMS(com.hazelcast.jet.core.TestProcessors.MockPMS) MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Before(org.junit.Before)

Example 24 with MockPMS

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

the class ExecutionLifecycleTest method when_pmsCloseThrows_then_jobSucceeds.

@Test
public void when_pmsCloseThrows_then_jobSucceeds() {
    // Given
    RuntimeException e = new RuntimeException("mock error");
    DAG dag = new DAG().vertex(new Vertex("test", new MockPMS(() -> new MockPS(MockP::new, NODE_COUNT)).setCloseError(e)));
    // When
    Job job = instance.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) Test(org.junit.Test)

Example 25 with MockPMS

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

the class ExecutionLifecycleTest method when_psCloseThrows_then_jobSucceeds.

@Test
public void when_psCloseThrows_then_jobSucceeds() {
    // Given
    RuntimeException e = new RuntimeException("mock error");
    DAG dag = new DAG().vertex(new Vertex("faulty", new MockPMS(() -> new MockPS(MockP::new, NODE_COUNT).setCloseError(e))));
    // When
    Job job = instance.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) 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