Search in sources :

Example 6 with MockPS

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

the class ExecutionLifecycleTest method when_processorNonCooperativeCompleteThrows_then_failJob.

@Test
public void when_processorNonCooperativeCompleteThrows_then_failJob() {
    // Given
    DAG dag = new DAG();
    RuntimeException e = new RuntimeException("mock error");
    dag.newVertex("faulty", nonCooperativeP(new MockPMS(() -> new MockPS(() -> new MockP().setCompleteError(e), NODE_COUNT))));
    // When
    Job job = runJobExpectFailure(dag, e);
    // Then
    assertPClosedWithError(e, false);
    assertPsClosedWithError(e);
    assertPmsClosedWithError(e);
    assertJobFailed(job, e);
}
Also used : MockPMS(com.hazelcast.jet.core.TestProcessors.MockPMS) MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) MockP(com.hazelcast.jet.core.TestProcessors.MockP) Job(com.hazelcast.jet.Job) Test(org.junit.Test)

Example 7 with MockPS

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

the class JobTest method when_jobIsCompleted_then_trackedJobCanQueryJobResult.

@Test
public void when_jobIsCompleted_then_trackedJobCanQueryJobResult() throws InterruptedException {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT)));
    // When
    instance1.newJob(dag);
    StuckProcessor.executionStarted.await();
    Collection<Job> trackedJobs = instance2.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) StuckProcessor(com.hazelcast.jet.core.TestProcessors.StuckProcessor) Job(com.hazelcast.jet.Job) Test(org.junit.Test)

Example 8 with MockPS

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

the class JobTest method testGetJobByIdWhenJobIsRunning.

private void testGetJobByIdWhenJobIsRunning(JetInstance instance) throws InterruptedException {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT)));
    // When
    Job job = instance1.newJob(dag);
    StuckProcessor.executionStarted.await();
    // Then
    Job trackedJob = instance.getJob(job.getId());
    assertNotNull(trackedJob);
    assertEquals(job.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)

Example 9 with MockPS

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

the class JobTest method when_jobIsSubmitted_then_trackedJobCanQueryJobStatus.

@Test
public void when_jobIsSubmitted_then_trackedJobCanQueryJobStatus() throws InterruptedException {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT)));
    // When
    Job submittedJob = instance1.newJob(dag);
    StuckProcessor.executionStarted.await();
    Collection<Job> trackedJobs = instance2.getJobs();
    assertEquals(1, trackedJobs.size());
    Job trackedJob = trackedJobs.iterator().next();
    // Then
    assertTrueEventually(() -> assertEquals(RUNNING, trackedJob.getStatus()));
    submittedJob.cancel();
    joinAndExpectCancellation(submittedJob);
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) StuckProcessor(com.hazelcast.jet.core.TestProcessors.StuckProcessor) Job(com.hazelcast.jet.Job) Test(org.junit.Test)

Example 10 with MockPS

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

the class JobTest method testGetJobByNameWhenJobIsRunning.

private void testGetJobByNameWhenJobIsRunning(JetInstance instance) throws InterruptedException {
    // 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);
    assertEquals(jobName, job.getName());
    StuckProcessor.executionStarted.await();
    // Then
    Job trackedJob = instance.getJob(jobName);
    assertNotNull(trackedJob);
    assertEquals(jobName, trackedJob.getName());
    assertEquals(job.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