Search in sources :

Example 31 with NoOutputSourceP

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

the class TopologyChangeTest method when_nonCoordinatorLeavesDuringExecution_then_jobRestarts.

@Test
public void when_nonCoordinatorLeavesDuringExecution_then_jobRestarts() throws Throwable {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, nodeCount)));
    // When
    Job job = instances[0].getJet().newJob(dag);
    NoOutputSourceP.executionStarted.await();
    instances[2].getLifecycleService().terminate();
    NoOutputSourceP.proceedLatch.countDown();
    job.join();
    // upon non-coordinator member leave, remaining members restart and complete the job
    final int count = nodeCount * 2 - 1;
    assertEquals(count, MockPS.initCount.get());
    assertTrueEventually(() -> {
        assertEquals(count, MockPS.closeCount.get());
        assertEquals(nodeCount, MockPS.receivedCloseErrors.size());
        for (int i = 0; i < MockPS.receivedCloseErrors.size(); i++) {
            Throwable error = MockPS.receivedCloseErrors.get(i);
            assertTrue(error instanceof CancellationException);
        }
    });
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) CancellationException(java.util.concurrent.CancellationException) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Job(com.hazelcast.jet.Job) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 32 with NoOutputSourceP

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

the class TopologyChangeTest method when_coordinatorLeavesDuringExecution_then_nonCoordinatorJobSubmitterStillGetsJobResult.

@Test
public void when_coordinatorLeavesDuringExecution_then_nonCoordinatorJobSubmitterStillGetsJobResult() throws Throwable {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, nodeCount)));
    // When
    Job job = instances[1].getJet().newJob(dag);
    NoOutputSourceP.executionStarted.await();
    instances[0].getLifecycleService().terminate();
    NoOutputSourceP.proceedLatch.countDown();
    // Then
    job.join();
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Job(com.hazelcast.jet.Job) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 33 with NoOutputSourceP

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

the class TopologyChangeTest method when_coordinatorLeaves_AutoScalingOff_then_jobFailsOrSuspends.

private void when_coordinatorLeaves_AutoScalingOff_then_jobFailsOrSuspends(boolean snapshotted) throws Throwable {
    // Given
    HazelcastInstance client = createHazelcastClient();
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, nodeCount)));
    JobConfig config = new JobConfig();
    config.setAutoScaling(false);
    config.setProcessingGuarantee(snapshotted ? EXACTLY_ONCE : NONE);
    // When
    Job job = client.getJet().newJob(dag, config);
    NoOutputSourceP.executionStarted.await();
    instances[0].getLifecycleService().terminate();
    NoOutputSourceP.proceedLatch.countDown();
    assertTrueEventually(() -> {
        JobStatus status = null;
        while (status == null) {
            try {
                status = job.getStatus();
            } catch (TargetNotMemberException ignored) {
            }
        }
        assertEquals(snapshotted ? SUSPENDED : FAILED, status);
    }, 10);
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) HazelcastInstance(com.hazelcast.core.HazelcastInstance) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig)

Example 34 with NoOutputSourceP

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

the class TopologyChangeTest method when_addAndRemoveNodeDuringExecution_then_completeSuccessfully.

@Test
public void when_addAndRemoveNodeDuringExecution_then_completeSuccessfully() throws Throwable {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, nodeCount)));
    // When
    Job job = instances[0].getJet().newJob(dag);
    NoOutputSourceP.executionStarted.await();
    HazelcastInstance instance = createHazelcastInstance(config);
    instance.shutdown();
    NoOutputSourceP.proceedLatch.countDown();
    job.join();
    // Then
    assertEquals(nodeCount, MockPS.initCount.get());
    assertTrueEventually(() -> {
        assertEquals(nodeCount, MockPS.closeCount.get());
        assertThat(MockPS.receivedCloseErrors, empty());
    });
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) HazelcastInstance(com.hazelcast.core.HazelcastInstance) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Job(com.hazelcast.jet.Job) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 35 with NoOutputSourceP

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

the class TopologyChangeTest method when_nonCoordinatorLeaves_AutoScalingOff_then_jobFailsOrSuspends.

private void when_nonCoordinatorLeaves_AutoScalingOff_then_jobFailsOrSuspends(boolean snapshotted) throws Throwable {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, nodeCount)));
    JobConfig config = new JobConfig();
    config.setAutoScaling(false);
    config.setProcessingGuarantee(snapshotted ? EXACTLY_ONCE : NONE);
    // When
    Job job = instances[0].getJet().newJob(dag, config);
    NoOutputSourceP.executionStarted.await();
    instances[2].getLifecycleService().terminate();
    NoOutputSourceP.proceedLatch.countDown();
    assertJobStatusEventually(job, snapshotted ? SUSPENDED : FAILED, 10);
    if (!snapshotted) {
        try {
            job.join();
            fail("join didn't fail");
        } catch (Exception e) {
            assertContains(e.getMessage(), TopologyChangedException.class.getName());
            assertContains(e.getMessage(), "[127.0.0.1]:5703=" + MemberLeftException.class.getName());
        }
    }
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) CancellationException(java.util.concurrent.CancellationException) TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) ExpectedException(org.junit.rules.ExpectedException) MemberLeftException(com.hazelcast.core.MemberLeftException) ExecutionException(java.util.concurrent.ExecutionException) MemberLeftException(com.hazelcast.core.MemberLeftException)

Aggregations

NoOutputSourceP (com.hazelcast.jet.core.TestProcessors.NoOutputSourceP)68 Job (com.hazelcast.jet.Job)64 Test (org.junit.Test)54 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)52 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)43 QuickTest (com.hazelcast.test.annotation.QuickTest)33 JobConfig (com.hazelcast.jet.config.JobConfig)31 HazelcastInstance (com.hazelcast.core.HazelcastInstance)22 NightlyTest (com.hazelcast.test.annotation.NightlyTest)11 CancellationException (java.util.concurrent.CancellationException)11 CountDownLatch (java.util.concurrent.CountDownLatch)11 SlowTest (com.hazelcast.test.annotation.SlowTest)10 Config (com.hazelcast.config.Config)9 JetServiceBackend (com.hazelcast.jet.impl.JetServiceBackend)9 JobRepository (com.hazelcast.jet.impl.JobRepository)9 Future (java.util.concurrent.Future)8 ExpectedException (org.junit.rules.ExpectedException)8 JobExecutionRecord (com.hazelcast.jet.impl.JobExecutionRecord)7 MasterContext (com.hazelcast.jet.impl.MasterContext)7 ClusterService (com.hazelcast.internal.cluster.ClusterService)6