Search in sources :

Example 1 with MockP

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

the class ExceptionUtilTest method test_serializationFromNodeToClient.

@Test
public void test_serializationFromNodeToClient() {
    // create one member and one client
    createJetMember();
    JetInstance client = createJetClient();
    RuntimeException exc = new RuntimeException("myException");
    try {
        DAG dag = new DAG();
        dag.newVertex("source", () -> new MockP().setCompleteError(exc)).localParallelism(1);
        client.newJob(dag).join();
    } catch (Exception caught) {
        assertThat(caught.toString(), containsString(exc.toString()));
        TestUtil.assertExceptionInCauses(exc, caught);
    } finally {
        shutdownFactory();
    }
}
Also used : JetInstance(com.hazelcast.jet.JetInstance) MockP(com.hazelcast.jet.core.TestProcessors.MockP) DAG(com.hazelcast.jet.core.DAG) JetException(com.hazelcast.jet.JetException) ExecutionException(java.util.concurrent.ExecutionException) ExpectedException(org.junit.rules.ExpectedException) Test(org.junit.Test)

Example 2 with MockP

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

the class ExecutionLifecycleTest method when_pmsInitThrows_then_jobFails.

@Test
public void when_pmsInitThrows_then_jobFails() {
    // Given
    RuntimeException e = new RuntimeException("mock error");
    DAG dag = new DAG().vertex(new Vertex("test", new MockPMS(() -> new MockPS(MockP::new, NODE_COUNT)).setInitError(e)));
    // When
    Job job = runJobExpectFailure(dag, e);
    // Then
    assertPmsClosedWithError(e);
    assertJobFailed(job, e);
}
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 3 with MockP

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

the class ExecutionLifecycleTest method when_processorInitThrows_then_failJob.

@Test
public void when_processorInitThrows_then_failJob() {
    // Given
    DAG dag = new DAG();
    RuntimeException e = new RuntimeException("mock error");
    dag.newVertex("faulty", new MockPMS(() -> new MockPS(() -> new MockP().setInitError(e), NODE_COUNT)));
    // When
    Job job = runJobExpectFailure(dag, e);
    // Then
    assertPClosedWithError(e, true);
    assertPsClosedWithError(e);
    assertPmsClosedWithError(e);
    assertJobFailed(job, e);
}
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 4 with MockP

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

the class ExecutionLifecycleTest method when_pmsGetThrows_then_jobFails.

@Test
public void when_pmsGetThrows_then_jobFails() {
    // Given
    RuntimeException e = new RuntimeException("mock error");
    DAG dag = new DAG().vertex(new Vertex("faulty", new MockPMS(() -> new MockPS(MockP::new, NODE_COUNT)).setGetError(e)));
    // When
    Job job = runJobExpectFailure(dag, e);
    // Then
    assertPmsClosedWithError(e);
    assertJobFailed(job, e);
}
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 5 with MockP

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

the class ExecutionLifecycleTest method when_processorNonCooperativeCompleteThrows_then_failJob.

@Test
public void when_processorNonCooperativeCompleteThrows_then_failJob() {
    // Given
    DAG dag = new DAG();
    RuntimeException e = new RuntimeException("mock error");
    dag.newVertex("faulty", nonCooperativeP(new MockPMS(() -> new MockPS(() -> new MockP().setCompleteError(e), NODE_COUNT))));
    // When
    Job job = runJobExpectFailure(dag, e);
    // Then
    assertPClosedWithError(e, false);
    assertPsClosedWithError(e);
    assertPmsClosedWithError(e);
    assertJobFailed(job, e);
}
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

MockP (com.hazelcast.jet.core.TestProcessors.MockP)56 Test (org.junit.Test)54 Job (com.hazelcast.jet.Job)49 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)35 QuickTest (com.hazelcast.test.annotation.QuickTest)35 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)30 MockPMS (com.hazelcast.jet.core.TestProcessors.MockPMS)26 HazelcastInstance (com.hazelcast.core.HazelcastInstance)14 JobConfig (com.hazelcast.jet.config.JobConfig)11 DAG (com.hazelcast.jet.core.DAG)9 ExecutionException (java.util.concurrent.ExecutionException)8 ExpectedException (org.junit.rules.ExpectedException)5 JetException (com.hazelcast.jet.JetException)4 Processor (com.hazelcast.jet.core.Processor)4 ExpectedRuntimeException (com.hazelcast.test.ExpectedRuntimeException)4 NoOutputSourceP (com.hazelcast.jet.core.TestProcessors.NoOutputSourceP)3 Config (com.hazelcast.config.Config)2 JetInstance (com.hazelcast.jet.JetInstance)2 StuckProcessor (com.hazelcast.jet.core.TestProcessors.StuckProcessor)2 NightlyTest (com.hazelcast.test.annotation.NightlyTest)2