Search in sources :

Example 11 with MockPS

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

the class JobTest method when_jobIsCompleted_then_jobSubmissionTimeIsQueried.

@Test
public void when_jobIsCompleted_then_jobSubmissionTimeIsQueried() {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT)));
    JobConfig config = new JobConfig();
    String jobName = "job1";
    config.setName(jobName);
    // When
    Job job = instance1.newJob(dag, config);
    StuckProcessor.proceedLatch.countDown();
    job.join();
    Job trackedJob = instance1.getJob("job1");
    // Then
    assertNotNull(trackedJob);
    assertNotEquals(0, job.getSubmissionTime());
    assertNotEquals(0, trackedJob.getSubmissionTime());
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) StuckProcessor(com.hazelcast.jet.core.TestProcessors.StuckProcessor) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig) Test(org.junit.Test)

Example 12 with MockPS

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

the class JobTest method when_jobIsCompleted_then_trackedJobCanQueryJobResultFromClient.

@Test
public void when_jobIsCompleted_then_trackedJobCanQueryJobResultFromClient() throws InterruptedException {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT)));
    // When
    instance1.newJob(dag);
    StuckProcessor.executionStarted.await();
    JetInstance client = createJetClient();
    Collection<Job> trackedJobs = client.getJobs();
    assertEquals(1, trackedJobs.size());
    Job trackedJob = trackedJobs.iterator().next();
    StuckProcessor.proceedLatch.countDown();
    // Then
    trackedJob.join();
    assertEquals(COMPLETED, trackedJob.getStatus());
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) JetInstance(com.hazelcast.jet.JetInstance) StuckProcessor(com.hazelcast.jet.core.TestProcessors.StuckProcessor) Job(com.hazelcast.jet.Job) Test(org.junit.Test)

Example 13 with MockPS

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

the class JobTest method testGetJobsByNameWhenJobsAreRunning.

private void testGetJobsByNameWhenJobsAreRunning(JetInstance instance) throws InterruptedException {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT * 2)));
    JobConfig config = new JobConfig();
    String jobName = "job1";
    config.setName(jobName);
    // When
    Job job1 = instance1.newJob(dag, config);
    sleepAtLeastMillis(1);
    Job job2 = instance1.newJob(dag, config);
    StuckProcessor.executionStarted.await();
    // Then
    List<Job> jobs = instance.getJobs(jobName);
    assertEquals(2, jobs.size());
    Job trackedJob1 = jobs.get(0);
    Job trackedJob2 = jobs.get(1);
    assertEquals(job2.getId(), trackedJob1.getId());
    assertEquals(jobName, trackedJob1.getName());
    assertTrueEventually(() -> assertEquals(RUNNING, trackedJob1.getStatus()));
    assertEquals(job1.getId(), trackedJob2.getId());
    assertEquals(jobName, trackedJob2.getName());
    assertTrueEventually(() -> assertEquals(RUNNING, trackedJob2.getStatus()));
    StuckProcessor.proceedLatch.countDown();
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) StuckProcessor(com.hazelcast.jet.core.TestProcessors.StuckProcessor) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig)

Example 14 with MockPS

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

the class JobTest method when_lastSubmittedJobIsCompletedBeforePreviouslySubmittedRunningJob_then_itIsQueriedByName.

@Test
public void when_lastSubmittedJobIsCompletedBeforePreviouslySubmittedRunningJob_then_itIsQueriedByName() {
    // Given
    DAG dag1 = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT)));
    DAG dag2 = new DAG().vertex(new Vertex("test", new MockPS(Identity::new, NODE_COUNT)));
    JobConfig config = new JobConfig();
    String jobName = "job1";
    config.setName(jobName);
    // When
    Job job1 = instance1.newJob(dag1, config);
    sleepAtLeastMillis(1);
    Job job2 = instance1.newJob(dag2, config);
    job2.join();
    // Then
    Job trackedJob = instance1.getJob(jobName);
    assertNotNull(trackedJob);
    assertEquals(jobName, trackedJob.getName());
    assertNotEquals(job1.getId(), trackedJob.getId());
    assertEquals(job2.getId(), trackedJob.getId());
    assertEquals(COMPLETED, trackedJob.getStatus());
    StuckProcessor.proceedLatch.countDown();
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) StuckProcessor(com.hazelcast.jet.core.TestProcessors.StuckProcessor) Identity(com.hazelcast.jet.core.TestProcessors.Identity) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig) Test(org.junit.Test)

Example 15 with MockPS

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

the class JobTest method testGetJobByNameWhenMultipleJobsAreRunning.

private void testGetJobByNameWhenMultipleJobsAreRunning(JetInstance instance) throws InterruptedException {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT * 2)));
    JobConfig config = new JobConfig();
    String jobName = "job1";
    config.setName(jobName);
    // When
    Job job1 = instance1.newJob(dag, config);
    sleepAtLeastMillis(1);
    Job job2 = instance1.newJob(dag, config);
    StuckProcessor.executionStarted.await();
    // Then
    Job trackedJob = instance.getJob(jobName);
    assertNotNull(trackedJob);
    assertEquals(jobName, trackedJob.getName());
    assertNotEquals(job1.getId(), trackedJob.getId());
    assertEquals(job2.getId(), trackedJob.getId());
    assertTrueEventually(() -> assertEquals(RUNNING, trackedJob.getStatus()));
    StuckProcessor.proceedLatch.countDown();
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) StuckProcessor(com.hazelcast.jet.core.TestProcessors.StuckProcessor) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig)

Aggregations

MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)135 Job (com.hazelcast.jet.Job)127 Test (org.junit.Test)115 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)56 NoOutputSourceP (com.hazelcast.jet.core.TestProcessors.NoOutputSourceP)53 JobConfig (com.hazelcast.jet.config.JobConfig)49 QuickTest (com.hazelcast.test.annotation.QuickTest)42 StuckProcessor (com.hazelcast.jet.core.TestProcessors.StuckProcessor)40 MockPMS (com.hazelcast.jet.core.TestProcessors.MockPMS)31 MockP (com.hazelcast.jet.core.TestProcessors.MockP)30 HazelcastInstance (com.hazelcast.core.HazelcastInstance)21 CountDownLatch (java.util.concurrent.CountDownLatch)21 JobRepository (com.hazelcast.jet.impl.JobRepository)18 CancellationException (java.util.concurrent.CancellationException)16 Future (java.util.concurrent.Future)16 JetInstance (com.hazelcast.jet.JetInstance)15 MasterContext (com.hazelcast.jet.impl.MasterContext)15 ExpectedException (org.junit.rules.ExpectedException)15 STARTING (com.hazelcast.jet.core.JobStatus.STARTING)14 SlowTest (com.hazelcast.test.annotation.SlowTest)14