Search in sources :

Example 61 with NoOutputSourceP

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

the class JobTest method when_suspendedNamedJob_then_newJobWithEqualNameFails.

@Test
public void when_suspendedNamedJob_then_newJobWithEqualNameFails() {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT * 2)));
    JobConfig config = new JobConfig().setName(randomName());
    // When
    Job job1 = instance().getJet().newJob(dag, config);
    assertJobStatusEventually(job1, RUNNING);
    job1.suspend();
    assertJobStatusEventually(job1, SUSPENDED);
    // Then
    assertThatThrownBy(() -> instances()[1].getJet().newJob(dag, config)).isInstanceOf(JobAlreadyExistsException.class);
}
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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 62 with NoOutputSourceP

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

the class JobTest method when_jobIsCompleted_then_itIsQueriedById.

@Test
public void when_jobIsCompleted_then_itIsQueriedById() {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
    // When
    Job job = instance().getJet().newJob(dag);
    NoOutputSourceP.proceedLatch.countDown();
    job.join();
    // Then
    Job trackedJob = instance().getJet().getJob(job.getId());
    assertNotNull(trackedJob);
    assertEquals(job.getId(), trackedJob.getId());
    assertEquals(COMPLETED, trackedJob.getStatus());
}
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 63 with NoOutputSourceP

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

the class JobTest method when_jobConfigChanged_then_doesNotAffectSubmittedJob.

@Test
public void when_jobConfigChanged_then_doesNotAffectSubmittedJob() {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT * 2)));
    JobConfig config = new JobConfig().setName(randomName());
    Job job1 = instance().getJet().newJob(dag, config);
    assertJobStatusEventually(job1, RUNNING);
    // When
    config.setName(randomName());
    // Then
    Job job2 = instance().getJet().newJob(dag, config);
    assertJobStatusEventually(job2, RUNNING);
}
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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 64 with NoOutputSourceP

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

the class JobTest method when_suspendedNamedJob_then_newJobIfAbsentWithEqualNameJoinsIt.

@Test
public void when_suspendedNamedJob_then_newJobIfAbsentWithEqualNameJoinsIt() {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT * 2)));
    JobConfig config = new JobConfig().setName(randomName());
    // When
    Job job1 = instance().getJet().newJob(dag, config);
    assertJobStatusEventually(job1, RUNNING);
    job1.suspend();
    assertJobStatusEventually(job1, SUSPENDED);
    // Then
    Job job2 = instances()[1].getJet().newJobIfAbsent(dag, config);
    assertEquals(job1.getId(), job2.getId());
    assertEquals(job2.getStatus(), SUSPENDED);
}
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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 65 with NoOutputSourceP

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

the class JobTest method when_jobIsCompleted_then_itIsQueriedByName.

@Test
public void when_jobIsCompleted_then_itIsQueriedByName() {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
    JobConfig config = new JobConfig();
    String jobName = randomName();
    config.setName(jobName);
    // When
    Job job = instance().getJet().newJob(dag, config);
    NoOutputSourceP.proceedLatch.countDown();
    job.join();
    // Then
    Job trackedJob = instance().getJet().getJob(jobName);
    assertNotNull(trackedJob);
    assertEquals(jobName, trackedJob.getName());
    assertEquals(job.getId(), trackedJob.getId());
    assertEquals(COMPLETED, trackedJob.getStatus());
}
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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

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