Search in sources :

Example 11 with MockP

use of com.hazelcast.jet.core.TestProcessors.MockP 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)

Example 12 with MockP

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

the class JobTest method when_lightJob_then_unsupportedMethodsThrow.

// ### Tests for light jobs
@Test
public void when_lightJob_then_unsupportedMethodsThrow() {
    DAG streamingDag = new DAG();
    streamingDag.newVertex("v", () -> new MockP().streaming());
    // When
    Job job = instance().getJet().newLightJob(streamingDag);
    // Then
    assertThatThrownBy(job::getSuspensionCause).isInstanceOf(UnsupportedOperationException.class);
    assertThatThrownBy(job::getMetrics).isInstanceOf(UnsupportedOperationException.class);
    assertThatThrownBy(job::restart).isInstanceOf(UnsupportedOperationException.class);
    assertThatThrownBy(job::suspend).isInstanceOf(UnsupportedOperationException.class);
    assertThatThrownBy(job::resume).isInstanceOf(UnsupportedOperationException.class);
    assertThatThrownBy(() -> job.cancelAndExportSnapshot("foo")).isInstanceOf(UnsupportedOperationException.class);
    assertThatThrownBy(() -> job.exportSnapshot("foo")).isInstanceOf(UnsupportedOperationException.class);
}
Also used : 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 MockP

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

the class MemberReconnectionTest method when_connectionDropped_then_detectedInReceiverTaskletAndFails.

@Test
public void when_connectionDropped_then_detectedInReceiverTaskletAndFails() {
    // we use real-network instances, closing the mock connection doesn't cause them to reconnect
    Config config = smallInstanceConfig();
    config.setClusterName(randomName());
    HazelcastInstance inst1 = createHazelcastInstance(config);
    HazelcastInstance inst2 = createHazelcastInstance(config);
    DAG dag = new DAG();
    Vertex v1 = dag.newVertex("v1", () -> new MockP().streaming());
    Vertex v2 = dag.newVertex("v2", () -> new MockP());
    dag.edge(between(v1, v2).distributed());
    Job job = inst1.getJet().newJob(dag);
    long executionId = assertJobRunningEventually(inst1, job, null);
    // Close the connection. Nothing is sent through the SenderTasklet, therefore we won't detect
    // it there. We rely on detecting it in ReceiverTasklet, we assert that it was detected there.
    logger.info("closing the connection...");
    ImdgUtil.getMemberConnection(getNodeEngineImpl(inst1), getNodeEngineImpl(inst2).getThisAddress()).close("mock close", new Exception("mock close"));
    // assert that the job was restarted
    assertJobRunningEventually(inst1, job, executionId);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) MockP(com.hazelcast.jet.core.TestProcessors.MockP) Job(com.hazelcast.jet.Job) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 14 with MockP

use of com.hazelcast.jet.core.TestProcessors.MockP 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 15 with MockP

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

the class JobTest method when_jobFailed_then_jobStatusIsCompletedEventually.

@Test
public void when_jobFailed_then_jobStatusIsCompletedEventually() throws InterruptedException {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS((SupplierEx<Processor>) () -> new MockP().setCompleteError(new ExpectedRuntimeException()), NODE_COUNT)));
    // When
    Job job = instance().getJet().newJob(dag);
    // Then
    try {
        job.getFuture().get();
        fail();
    } catch (ExecutionException expected) {
        assertEquals(FAILED, job.getStatus());
    }
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) MockP(com.hazelcast.jet.core.TestProcessors.MockP) Job(com.hazelcast.jet.Job) ExecutionException(java.util.concurrent.ExecutionException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) 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