Search in sources :

Example 66 with NoOutputSourceP

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

the class JobTest method when_jobCancelled_then_trackedJobCanQueryResult.

@Test
public void when_jobCancelled_then_trackedJobCanQueryResult() throws InterruptedException {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
    // When
    Job submittedJob = instance().getJet().newJob(dag);
    NoOutputSourceP.executionStarted.await();
    Collection<Job> trackedJobs = instances()[1].getJet().getJobs();
    Job trackedJob = trackedJobs.stream().filter(j -> j.getId() == submittedJob.getId()).findFirst().orElse(null);
    assertNotNull(trackedJob);
    submittedJob.cancel();
    // Then
    joinAndExpectCancellation(trackedJob);
    NoOutputSourceP.proceedLatch.countDown();
    assertJobStatusEventually(trackedJob, FAILED);
}
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) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 67 with NoOutputSourceP

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

the class JobTest method when_namedJobCompletedAndAnotherSubmitted_then_bothAreQueriedByName.

@Test
public void when_namedJobCompletedAndAnotherSubmitted_then_bothAreQueriedByName() {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT * 2)));
    JobConfig config = new JobConfig();
    String jobName = randomName();
    config.setName(jobName);
    // When
    Job job1 = instance().getJet().newJob(dag, config);
    NoOutputSourceP.proceedLatch.countDown();
    job1.join();
    NoOutputSourceP.proceedLatch = new CountDownLatch(1);
    Job job2 = instance().getJet().newJob(dag, config);
    assertTrueEventually(() -> assertEquals(RUNNING, job2.getStatus()));
    // Then
    List<Job> trackedJobs = instance().getJet().getJobs(jobName);
    assertEquals(2, trackedJobs.size());
    Job trackedJob1 = trackedJobs.get(0);
    Job trackedJob2 = trackedJobs.get(1);
    assertEquals(job2.getId(), trackedJob1.getId());
    assertEquals(RUNNING, trackedJob1.getStatus());
    assertEquals(job1.getId(), trackedJob2.getId());
    assertEquals(COMPLETED, trackedJob2.getStatus());
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Job(com.hazelcast.jet.Job) CountDownLatch(java.util.concurrent.CountDownLatch) JobConfig(com.hazelcast.jet.config.JobConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 68 with NoOutputSourceP

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

the class Job_StaleInstanceTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    TestProcessors.reset(1);
    instanceFactory = new TestHazelcastFactory();
    HazelcastInstance instance = instanceFactory.newHazelcastInstance(smallInstanceConfig());
    DAG dag = new DAG();
    dag.newVertex("v", () -> new NoOutputSourceP());
    client = instanceFactory.newHazelcastClient();
    job = client.getJet().newJob(dag);
    assertJobStatusEventually(job, RUNNING);
    instance.getLifecycleService().terminate();
    instance = instanceFactory.newHazelcastInstance(smallInstanceConfig());
    assertEqualsEventually(() -> firstItem(client.getCluster().getMembers()).map(Member::getAddress).orElse(null), instance.getCluster().getLocalMember().getAddress());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) TestHazelcastFactory(com.hazelcast.client.test.TestHazelcastFactory) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Member(com.hazelcast.cluster.Member) BeforeClass(org.junit.BeforeClass)

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