Search in sources :

Example 6 with JobResult

use of com.hazelcast.jet.impl.JobResult in project hazelcast by hazelcast.

the class SuspendResumeTest method when_cancelSuspendedJob_then_jobCancels.

@Test
public void when_cancelSuspendedJob_then_jobCancels() throws Exception {
    Job job = instances[0].getJet().newJob(dag);
    NoOutputSourceP.executionStarted.await();
    job.suspend();
    assertJobStatusEventually(job, SUSPENDED);
    // When-Then
    cancelAndJoin(job);
    assertJobStatusEventually(job, FAILED);
    // check that job resources are deleted
    JobRepository jobRepository = new JobRepository(instances[0]);
    assertTrueEventually(() -> {
        assertNull("JobRecord", jobRepository.getJobRecord(job.getId()));
        JobResult jobResult = jobRepository.getJobResult(job.getId());
        assertContains(jobResult.getFailureText(), CancellationException.class.getName());
        assertFalse("Job result successful", jobResult.isSuccessful());
    });
}
Also used : JobResult(com.hazelcast.jet.impl.JobResult) CancellationException(java.util.concurrent.CancellationException) Job(com.hazelcast.jet.Job) JobRepository(com.hazelcast.jet.impl.JobRepository) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 7 with JobResult

use of com.hazelcast.jet.impl.JobResult in project hazelcast by hazelcast.

the class ExecutionLifecycleTest method assertJobFailed.

private void assertJobFailed(Job job, Throwable expected) {
    assertTrue(job.getFuture().isDone());
    try {
        job.join();
        fail("job didn't fail");
    } catch (Throwable caught) {
        assertExceptionInCauses(expected, caught);
    }
    if (!job.isLightJob()) {
        Job normalJob = job;
        JobResult jobResult = getJobResult(normalJob);
        assertFalse("jobResult.isSuccessful", jobResult.isSuccessful());
        assertNotNull(jobResult.getFailureText());
        assertContains(jobResult.getFailureText(), expected.toString());
        assertEquals("jobStatus", JobStatus.FAILED, normalJob.getStatus());
    }
}
Also used : JobResult(com.hazelcast.jet.impl.JobResult) Job(com.hazelcast.jet.Job)

Example 8 with JobResult

use of com.hazelcast.jet.impl.JobResult in project hazelcast by hazelcast.

the class ExecutionLifecycleTest method getJobResult.

private JobResult getJobResult(Job job) {
    JetServiceBackend jetServiceBackend = getJetServiceBackend(instance());
    assertNull(jetServiceBackend.getJobRepository().getJobRecord(job.getId()));
    JobResult jobResult = jetServiceBackend.getJobRepository().getJobResult(job.getId());
    assertNotNull(jobResult);
    return jobResult;
}
Also used : JobResult(com.hazelcast.jet.impl.JobResult) JetServiceBackend(com.hazelcast.jet.impl.JetServiceBackend)

Example 9 with JobResult

use of com.hazelcast.jet.impl.JobResult in project hazelcast-jet by hazelcast.

the class ExecutionLifecycleTest method assertJobSucceeded.

private void assertJobSucceeded(Job job) {
    JobResult jobResult = getJobResult(job);
    assertTrue(jobResult.isSuccessful());
    assertNull(jobResult.getFailure());
}
Also used : JobResult(com.hazelcast.jet.impl.JobResult)

Aggregations

JobResult (com.hazelcast.jet.impl.JobResult)9 Job (com.hazelcast.jet.Job)4 JobRepository (com.hazelcast.jet.impl.JobRepository)3 CancellationException (java.util.concurrent.CancellationException)3 Test (org.junit.Test)3 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)2 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)2 JetServiceBackend (com.hazelcast.jet.impl.JetServiceBackend)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 SlowTest (com.hazelcast.test.annotation.SlowTest)2 ExecutionException (java.util.concurrent.ExecutionException)2 NoOutputSourceP (com.hazelcast.jet.core.TestProcessors.NoOutputSourceP)1 StuckProcessor (com.hazelcast.jet.core.TestProcessors.StuckProcessor)1 JetService (com.hazelcast.jet.impl.JetService)1