use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class JobTest method when_trackedJobCancels_then_jobCompletes.
@Test
public void when_trackedJobCancels_then_jobCompletes() {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
Job submittedJob = instance().getJet().newJob(dag);
Collection<Job> trackedJobs = instances()[1].getJet().getJobs();
Job trackedJob = trackedJobs.stream().filter(j -> j.getId() == submittedJob.getId()).findFirst().orElse(null);
assertNotNull(trackedJob);
// When
trackedJob.cancel();
// Then
joinAndExpectCancellation(trackedJob);
joinAndExpectCancellation(submittedJob);
NoOutputSourceP.proceedLatch.countDown();
assertJobStatusEventually(trackedJob, FAILED);
assertJobStatusEventually(submittedJob, FAILED);
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class JobTest method when_jobCompleted_then_trackedJobCanQueryResultFromClient.
@Test
public void when_jobCompleted_then_trackedJobCanQueryResultFromClient() throws InterruptedException {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
// When
Job submittedJob = instance().getJet().newJob(dag);
NoOutputSourceP.executionStarted.await();
Collection<Job> trackedJobs = client().getJet().getJobs();
Job trackedJob = trackedJobs.stream().filter(j -> j.getId() == submittedJob.getId()).findFirst().orElse(null);
assertNotNull(trackedJob);
NoOutputSourceP.proceedLatch.countDown();
// Then
trackedJob.join();
assertEquals(COMPLETED, trackedJob.getStatus());
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class JobTest method when_namedJobIsRunning_then_newNamedSubmitJoinsExisting.
private void when_namedJobIsRunning_then_newNamedSubmitJoinsExisting(HazelcastInstance instance) {
// 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);
assertTrueEventually(() -> assertEquals(RUNNING, job1.getStatus()));
// When
Job job2 = instance.getJet().newJobIfAbsent(dag, config);
// Then
assertEquals(job1.getId(), job2.getId());
NoOutputSourceP.proceedLatch.countDown();
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class JobTest method when_jobCompleted_then_trackedJobCanQueryResult.
@Test
public void when_jobCompleted_then_trackedJobCanQueryResult() throws InterruptedException {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
// When
Job submittedJob = instance().getJet().newJob(dag);
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);
NoOutputSourceP.proceedLatch.countDown();
// Then
trackedJob.join();
assertEquals(COMPLETED, trackedJob.getStatus());
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class JobTest method when_namedJobCompletedAndAnotherSubmitted_then_runningOneIsQueriedByName.
@Test
public void when_namedJobCompletedAndAnotherSubmitted_then_runningOneIsQueriedByName() {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT * 2)));
JobConfig config = new JobConfig();
String jobName = randomName();
config.setName(jobName);
// When
Job job1 = instance().getJet().newJob(dag, config);
NoOutputSourceP.proceedLatch.countDown();
job1.join();
NoOutputSourceP.proceedLatch = new CountDownLatch(1);
Job job2 = instance().getJet().newJob(dag, config);
assertTrueEventually(() -> assertEquals(RUNNING, job2.getStatus()));
// Then
Job trackedJob = instance().getJet().getJob(jobName);
assertNotNull(trackedJob);
assertEquals(jobName, trackedJob.getName());
assertNotEquals(job1.getId(), trackedJob.getId());
assertEquals(job2.getId(), trackedJob.getId());
assertEquals(RUNNING, trackedJob.getStatus());
}
Aggregations