Search in sources :

Example 1 with SleepJobConfig

use of alluxio.job.SleepJobConfig in project alluxio by Alluxio.

the class WorkflowTrackerTest method testCleanup.

@Test
public void testCleanup() throws Exception {
    SleepJobConfig jobConfig = new SleepJobConfig(1);
    mPlanTracker.run(jobConfig, mCommandManager, mMockJobServerContext, mWorkers, 1);
    jobConfig = new SleepJobConfig(1);
    mPlanTracker.run(jobConfig, mCommandManager, mMockJobServerContext, mWorkers, 2);
    jobConfig = new SleepJobConfig(1);
    mPlanTracker.run(jobConfig, mCommandManager, mMockJobServerContext, mWorkers, 3);
    doAnswer(invocation -> {
        PlanConfig config = invocation.getArgument(0, PlanConfig.class);
        long jobId = invocation.getArgument(1, Long.class);
        mPlanTracker.run(config, mCommandManager, mMockJobServerContext, mWorkers, jobId);
        return null;
    }).when(mMockJobMaster).run(any(PlanConfig.class), any(Long.class));
    ArrayList<JobConfig> jobs = Lists.newArrayList();
    SleepJobConfig child1 = new SleepJobConfig(1);
    SleepJobConfig child2 = new SleepJobConfig(2);
    jobs.add(child1);
    jobs.add(child2);
    CompositeConfig config = new CompositeConfig(jobs, false);
    mWorkflowTracker.run(config, 0);
    try {
        mPlanTracker.run(new SleepJobConfig(1), mCommandManager, mMockJobServerContext, mWorkers, 4);
        fail();
    } catch (ResourceExhaustedException e) {
    // Should fail
    }
    mPlanTracker.coordinators().stream().filter(coordinator -> coordinator.getJobId() == 100).findFirst().get().setJobAsFailed("TestError", "failed");
    mPlanTracker.run(new SleepJobConfig(1), mCommandManager, mMockJobServerContext, mWorkers, 4);
    assertNotNull(mWorkflowTracker.getStatus(0, true));
    try {
        mPlanTracker.run(new SleepJobConfig(1), mCommandManager, mMockJobServerContext, mWorkers, 5);
        fail();
    } catch (ResourceExhaustedException e) {
    // Should fail
    }
    mPlanTracker.coordinators().stream().filter(coordinator -> coordinator.getJobId() == 101).findFirst().get().setJobAsFailed("TestError", "failed");
    mPlanTracker.run(new SleepJobConfig(1), mCommandManager, mMockJobServerContext, mWorkers, 5);
    assertNull(mWorkflowTracker.getStatus(100, true));
}
Also used : TestPlanConfig(alluxio.job.TestPlanConfig) JobServerContext(alluxio.job.JobServerContext) Status(alluxio.job.wire.Status) ArrayList(java.util.ArrayList) CommandManager(alluxio.master.job.command.CommandManager) WorkflowInfo(alluxio.job.wire.WorkflowInfo) Lists(com.google.common.collect.Lists) ResourceExhaustedException(alluxio.exception.status.ResourceExhaustedException) WorkerInfo(alluxio.wire.WorkerInfo) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Assert.fail(org.junit.Assert.fail) SleepJobConfig(alluxio.job.SleepJobConfig) Before(org.junit.Before) Assert.assertNotNull(org.junit.Assert.assertNotNull) CompositeConfig(alluxio.job.workflow.composite.CompositeConfig) JobMaster(alluxio.master.job.JobMaster) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) PlanInfo(alluxio.job.plan.meta.PlanInfo) Mockito.never(org.mockito.Mockito.never) Assert.assertNull(org.junit.Assert.assertNull) JobConfig(alluxio.job.JobConfig) PlanTracker(alluxio.master.job.plan.PlanTracker) PlanConfig(alluxio.job.plan.PlanConfig) Mockito.any(org.mockito.Mockito.any) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) ResourceExhaustedException(alluxio.exception.status.ResourceExhaustedException) SleepJobConfig(alluxio.job.SleepJobConfig) TestPlanConfig(alluxio.job.TestPlanConfig) PlanConfig(alluxio.job.plan.PlanConfig) CompositeConfig(alluxio.job.workflow.composite.CompositeConfig) SleepJobConfig(alluxio.job.SleepJobConfig) JobConfig(alluxio.job.JobConfig) Test(org.junit.Test)

Example 2 with SleepJobConfig

use of alluxio.job.SleepJobConfig in project alluxio by Alluxio.

the class CancelCommandTest method testCancel.

@Test
public void testCancel() throws Exception {
    long jobId = sJobMaster.run(new SleepJobConfig(150 * 1000));
    sJobShell.run("cancel", Long.toString(jobId));
    JobTestUtils.waitForJobStatus(sJobMaster, jobId, Status.CANCELED);
}
Also used : SleepJobConfig(alluxio.job.SleepJobConfig) Test(org.junit.Test)

Example 3 with SleepJobConfig

use of alluxio.job.SleepJobConfig in project alluxio by Alluxio.

the class CompositeIntegrationTest method nestedTest.

@Test
public void nestedTest() throws Exception {
    CompositeConfig config = new CompositeConfig(Lists.newArrayList(new CompositeConfig(Lists.newArrayList(new SleepJobConfig(2), new SleepJobConfig(3)), false), new SleepJobConfig(1)), true);
    long jobId = mJobMaster.run(config);
    waitForJobToFinish(jobId);
    JobInfo status = mJobMaster.getStatus(jobId);
    assertEquals(Status.COMPLETED, status.getStatus());
    List<JobInfo> children = status.getChildren();
    assertEquals(2, children.size());
    JobInfo child0 = children.get(0);
    assertEquals(child0, mJobMaster.getStatus(children.get(0).getId()));
    assertEquals(Status.COMPLETED, child0.getStatus());
    assertEquals(2, child0.getChildren().size());
    JobInfo child1 = children.get(1);
    assertEquals(child1, mJobMaster.getStatus(children.get(1).getId()));
    assertEquals(Status.COMPLETED, child1.getStatus());
    assertEquals(1, child1.getChildren().size());
}
Also used : JobInfo(alluxio.job.wire.JobInfo) SleepJobConfig(alluxio.job.SleepJobConfig) JobIntegrationTest(alluxio.job.JobIntegrationTest) Test(org.junit.Test)

Example 4 with SleepJobConfig

use of alluxio.job.SleepJobConfig in project alluxio by Alluxio.

the class CompositeIntegrationTest method waitParallel.

@Test
public void waitParallel() throws Exception {
    CompositeConfig config = new CompositeConfig(Lists.newArrayList(new SleepJobConfig(1000000), new SleepJobConfig(1)), false);
    long jobId = mJobMaster.run(config);
    JobInfo status = mJobMaster.getStatus(jobId);
    assertEquals(Status.RUNNING, status.getStatus());
    assertEquals(2, status.getChildren().size());
}
Also used : JobInfo(alluxio.job.wire.JobInfo) SleepJobConfig(alluxio.job.SleepJobConfig) JobIntegrationTest(alluxio.job.JobIntegrationTest) Test(org.junit.Test)

Example 5 with SleepJobConfig

use of alluxio.job.SleepJobConfig in project alluxio by Alluxio.

the class JobMasterClientRestApiTest method cancel.

@Test
public void cancel() throws Exception {
    long jobId = startJob(new SleepJobConfig(10 * Constants.SECOND_MS));
    // Sleep to make sure the run request and the cancel request are separated by a job worker
    // heartbeat. If not, job service will not handle that case correctly.
    CommonUtils.sleepMs(30);
    Map<String, String> params = Maps.newHashMap();
    params.put("jobId", Long.toString(jobId));
    new TestCase(mHostname, mPort, getEndpoint(ServiceConstants.CANCEL), params, HttpMethod.POST, null).run();
    waitForStatus(jobId, Status.CANCELED);
}
Also used : SleepJobConfig(alluxio.job.SleepJobConfig) Test(org.junit.Test)

Aggregations

SleepJobConfig (alluxio.job.SleepJobConfig)17 Test (org.junit.Test)16 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)6 JobInfo (alluxio.job.wire.JobInfo)5 JobConfig (alluxio.job.JobConfig)4 JobIntegrationTest (alluxio.job.JobIntegrationTest)3 JobServerContext (alluxio.job.JobServerContext)2 CompositeConfig (alluxio.job.workflow.composite.CompositeConfig)2 CommandManager (alluxio.master.job.command.CommandManager)2 WorkerInfo (alluxio.wire.WorkerInfo)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 ResourceExhaustedException (alluxio.exception.status.ResourceExhaustedException)1 RunTaskCommand (alluxio.grpc.RunTaskCommand)1 RunTaskContext (alluxio.job.RunTaskContext)1 TestPlanConfig (alluxio.job.TestPlanConfig)1 PlanConfig (alluxio.job.plan.PlanConfig)1 PlanInfo (alluxio.job.plan.meta.PlanInfo)1 Status (alluxio.job.wire.Status)1 WorkflowInfo (alluxio.job.wire.WorkflowInfo)1 JobMaster (alluxio.master.job.JobMaster)1