use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class JobTest method when_namedJobSubmittedWithNewJobIfAbsent_then_trackedJobCanQueryStatus.
@Test
public void when_namedJobSubmittedWithNewJobIfAbsent_then_trackedJobCanQueryStatus() throws InterruptedException {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
JobConfig config = new JobConfig().setName(randomName());
// When
Job submittedJob = instance().getJet().newJobIfAbsent(dag, config);
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);
// Then
assertJobStatusEventually(trackedJob, RUNNING);
cancelAndJoin(submittedJob);
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class JobTest method when_jobSubmittedWithNewJobIfAbsent_then_trackedJobCanQueryStatus.
@Test
public void when_jobSubmittedWithNewJobIfAbsent_then_trackedJobCanQueryStatus() throws InterruptedException {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
// When
Job submittedJob = instance().getJet().newJobIfAbsent(dag, new JobConfig());
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);
// Then
assertJobStatusEventually(trackedJob, RUNNING);
cancelAndJoin(submittedJob);
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast 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(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();
Job trackedJob = instance().getJet().getJob(jobName);
// Then
assertNotNull(trackedJob);
assertNotEquals(0, job.getSubmissionTime());
assertNotEquals(0, trackedJob.getSubmissionTime());
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class JobTest method when_jobCancelled_then_jobStatusIsCompletedEventually.
@Test
public void when_jobCancelled_then_jobStatusIsCompletedEventually() throws InterruptedException {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
// When
Job job = instance().getJet().newJob(dag);
NoOutputSourceP.executionStarted.await();
// Then
cancelAndJoin(job);
NoOutputSourceP.proceedLatch.countDown();
assertJobStatusEventually(job, FAILED);
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class JobTest method testGetJobByIdWhenJobIsRunning.
private void testGetJobByIdWhenJobIsRunning(HazelcastInstance instance) throws InterruptedException {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
// When
Job job = instance().getJet().newJob(dag);
NoOutputSourceP.executionStarted.await();
// Then
Job trackedJob = instance.getJet().getJob(job.getId());
assertNotNull(trackedJob);
assertEquals(job.getId(), trackedJob.getId());
assertJobStatusEventually(trackedJob, RUNNING);
NoOutputSourceP.proceedLatch.countDown();
}
Aggregations