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());
}
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());
}
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();
}
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();
}
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();
}
Aggregations