use of com.hazelcast.jet.core.TestProcessors.Identity in project hazelcast-jet by hazelcast.
the class JobTest method testJobStatusDuringStart.
private void testJobStatusDuringStart(JetInstance submitter) {
PSThatWaitsOnInit.initLatch = new CountDownLatch(1);
DAG dag = new DAG().vertex(new Vertex("test", new PSThatWaitsOnInit(Identity::new)));
// When
Job job = submitter.newJob(dag);
JobStatus status = job.getStatus();
assertTrue(status == NOT_STARTED || status == STARTING);
PSThatWaitsOnInit.initLatch.countDown();
// Then
assertCompletedEventually(job);
}
use of com.hazelcast.jet.core.TestProcessors.Identity 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();
}
use of com.hazelcast.jet.core.TestProcessors.Identity in project hazelcast by hazelcast.
the class JobTest method when_jobSubmittedWithNewJobIfAbsent_then_jobStatusIsStarting.
private void when_jobSubmittedWithNewJobIfAbsent_then_jobStatusIsStarting(HazelcastInstance submitter) {
PSThatWaitsOnInit.initLatch = new CountDownLatch(1);
DAG dag = new DAG().vertex(new Vertex("test", new PSThatWaitsOnInit(Identity::new)));
// When
Job job = submitter.getJet().newJobIfAbsent(dag, new JobConfig());
JobStatus status = job.getStatus();
assertTrue(status == NOT_RUNNING || status == STARTING);
PSThatWaitsOnInit.initLatch.countDown();
// Then
assertJobStatusEventually(job, COMPLETED);
}
use of com.hazelcast.jet.core.TestProcessors.Identity in project hazelcast by hazelcast.
the class JobTest method when_jobSubmitted_then_jobStatusIsStarting.
private void when_jobSubmitted_then_jobStatusIsStarting(HazelcastInstance submitter) {
PSThatWaitsOnInit.initLatch = new CountDownLatch(1);
DAG dag = new DAG().vertex(new Vertex("test", new PSThatWaitsOnInit(Identity::new)));
// When
Job job = submitter.getJet().newJob(dag);
JobStatus status = job.getStatus();
assertTrue(status == NOT_RUNNING || status == STARTING);
PSThatWaitsOnInit.initLatch.countDown();
// Then
assertJobStatusEventually(job, COMPLETED);
}
use of com.hazelcast.jet.core.TestProcessors.Identity in project hazelcast-jet by hazelcast.
the class JobTest method when_jobsAreCompletedInReverseOrderOfTheirSubmissionOrder_then_theyAreQueriedByName.
@Test
public void when_jobsAreCompletedInReverseOrderOfTheirSubmissionOrder_then_theyAreQueriedByName() {
// 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();
StuckProcessor.proceedLatch.countDown();
job1.join();
// Then
List<Job> jobs = instance1.getJobs(jobName);
assertEquals(2, jobs.size());
Job trackedJob1 = jobs.get(0);
Job trackedJob2 = jobs.get(1);
assertEquals(job2.getId(), trackedJob1.getId());
assertEquals(COMPLETED, trackedJob1.getStatus());
assertEquals(job1.getId(), trackedJob2.getId());
assertEquals(COMPLETED, trackedJob2.getStatus());
}
Aggregations