Search in sources :

Example 1 with TestPlanConfig

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

the class JobMasterTest method flowControl.

@Test
public void flowControl() throws Exception {
    PlanCoordinator coordinator = PowerMockito.mock(PlanCoordinator.class);
    mockStatic(PlanCoordinator.class);
    when(PlanCoordinator.create(any(CommandManager.class), any(JobServerContext.class), anyList(), anyLong(), any(JobConfig.class), any(Consumer.class))).thenReturn(coordinator);
    TestPlanConfig jobConfig = new TestPlanConfig("/test");
    for (long i = 0; i < TEST_JOB_MASTER_JOB_CAPACITY; i++) {
        mJobMaster.run(jobConfig);
    }
    try {
        mJobMaster.run(jobConfig);
        Assert.fail("should not be able to run more jobs than job master capacity");
    } catch (ResourceExhaustedException e) {
        Assert.assertEquals(ExceptionMessage.JOB_MASTER_FULL_CAPACITY.getMessage(ServerConfiguration.get(PropertyKey.JOB_MASTER_JOB_CAPACITY)), e.getMessage());
    }
}
Also used : TestPlanConfig(alluxio.job.TestPlanConfig) ResourceExhaustedException(alluxio.exception.status.ResourceExhaustedException) JobServerContext(alluxio.job.JobServerContext) CommandManager(alluxio.master.job.command.CommandManager) Consumer(java.util.function.Consumer) PlanCoordinator(alluxio.master.job.plan.PlanCoordinator) SleepJobConfig(alluxio.job.SleepJobConfig) JobConfig(alluxio.job.JobConfig) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with TestPlanConfig

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

the class JobMasterTest method run.

@Test
public void run() throws Exception {
    PlanCoordinator coordinator = PowerMockito.mock(PlanCoordinator.class);
    mockStatic(PlanCoordinator.class);
    when(PlanCoordinator.create(any(CommandManager.class), any(JobServerContext.class), anyList(), anyLong(), any(JobConfig.class), any(Consumer.class))).thenReturn(coordinator);
    TestPlanConfig jobConfig = new TestPlanConfig("/test");
    List<Long> jobIdList = new ArrayList<>();
    for (long i = 0; i < TEST_JOB_MASTER_JOB_CAPACITY; i++) {
        jobIdList.add(mJobMaster.run(jobConfig));
    }
    final List<Long> list = mJobMaster.list(ListAllPOptions.getDefaultInstance());
    Assert.assertEquals(jobIdList, list);
    Assert.assertEquals(TEST_JOB_MASTER_JOB_CAPACITY, mJobMaster.list(ListAllPOptions.getDefaultInstance()).size());
}
Also used : TestPlanConfig(alluxio.job.TestPlanConfig) JobServerContext(alluxio.job.JobServerContext) CommandManager(alluxio.master.job.command.CommandManager) Consumer(java.util.function.Consumer) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) ArrayList(java.util.ArrayList) PlanCoordinator(alluxio.master.job.plan.PlanCoordinator) SleepJobConfig(alluxio.job.SleepJobConfig) JobConfig(alluxio.job.JobConfig) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with TestPlanConfig

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

the class WorkflowTrackerTest method testBasic.

@Test
public void testBasic() throws Exception {
    ArrayList<JobConfig> jobs = Lists.newArrayList();
    TestPlanConfig child1 = new TestPlanConfig("1");
    TestPlanConfig child2 = new TestPlanConfig("2");
    jobs.add(child1);
    jobs.add(child2);
    CompositeConfig config = new CompositeConfig(jobs, true);
    mWorkflowTracker.run(config, 0);
    verify(mMockJobMaster).run(child1, 100);
    WorkflowInfo info = mWorkflowTracker.getStatus(0, true);
    assertEquals(Status.RUNNING, info.getStatus());
    verify(mMockJobMaster, never()).run(child2, 101);
    PlanInfo plan100 = new PlanInfo(100, child1, null);
    plan100.setStatus(Status.COMPLETED);
    mWorkflowTracker.onPlanStatusChange(plan100);
    verify(mMockJobMaster).run(child2, 101);
    assertEquals(Status.RUNNING, mWorkflowTracker.getStatus(0, true).getStatus());
    PlanInfo plan101 = new PlanInfo(101, child2, null);
    plan101.setStatus(Status.COMPLETED);
    mWorkflowTracker.onPlanStatusChange(plan101);
    assertEquals(Status.COMPLETED, mWorkflowTracker.getStatus(0, true).getStatus());
}
Also used : TestPlanConfig(alluxio.job.TestPlanConfig) PlanInfo(alluxio.job.plan.meta.PlanInfo) WorkflowInfo(alluxio.job.wire.WorkflowInfo) CompositeConfig(alluxio.job.workflow.composite.CompositeConfig) SleepJobConfig(alluxio.job.SleepJobConfig) JobConfig(alluxio.job.JobConfig) Test(org.junit.Test)

Example 4 with TestPlanConfig

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

the class CommandManagerTest method submitRunTaskCommand.

@Test
public void submitRunTaskCommand() throws Exception {
    long jobId = 0L;
    int taskId = 1;
    JobConfig jobConfig = new TestPlanConfig("/test");
    long workerId = 2L;
    List<Integer> args = Lists.newArrayList(1);
    mManager.submitRunTaskCommand(jobId, taskId, jobConfig, args, workerId);
    List<JobCommand> commands = mManager.pollAllPendingCommands(workerId);
    Assert.assertEquals(1, commands.size());
    JobCommand command = commands.get(0);
    Assert.assertEquals(jobId, command.getRunTaskCommand().getJobId());
    Assert.assertEquals(taskId, command.getRunTaskCommand().getTaskId());
    Assert.assertEquals(jobConfig, SerializationUtils.deserialize(command.getRunTaskCommand().getJobConfig().toByteArray()));
    Assert.assertEquals(args, SerializationUtils.deserialize(command.getRunTaskCommand().getTaskArgs().toByteArray()));
}
Also used : TestPlanConfig(alluxio.job.TestPlanConfig) JobCommand(alluxio.grpc.JobCommand) JobConfig(alluxio.job.JobConfig) Test(org.junit.Test)

Example 5 with TestPlanConfig

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

the class SerializationUtilsTest method basicTest.

@Test
public void basicTest() throws Exception {
    TestPlanConfig config = new TestPlanConfig("test");
    byte[] bytes = SerializationUtils.serialize(config);
    Object deserialized = SerializationUtils.deserialize(bytes);
    Assert.assertTrue(deserialized instanceof TestPlanConfig);
    Assert.assertEquals(config, deserialized);
}
Also used : TestPlanConfig(alluxio.job.TestPlanConfig) Test(org.junit.Test)

Aggregations

TestPlanConfig (alluxio.job.TestPlanConfig)10 Test (org.junit.Test)10 JobConfig (alluxio.job.JobConfig)8 SleepJobConfig (alluxio.job.SleepJobConfig)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 JobServerContext (alluxio.job.JobServerContext)3 PlanInfo (alluxio.job.plan.meta.PlanInfo)3 CommandManager (alluxio.master.job.command.CommandManager)3 PlanCoordinator (alluxio.master.job.plan.PlanCoordinator)3 Consumer (java.util.function.Consumer)3 JobCommand (alluxio.grpc.JobCommand)2 ArrayList (java.util.ArrayList)2 ArgumentMatchers.anyLong (org.mockito.ArgumentMatchers.anyLong)2 ResourceExhaustedException (alluxio.exception.status.ResourceExhaustedException)1 RunTaskCommand (alluxio.grpc.RunTaskCommand)1 RunTaskContext (alluxio.job.RunTaskContext)1 JobWorkerHealth (alluxio.job.wire.JobWorkerHealth)1 WorkflowInfo (alluxio.job.wire.WorkflowInfo)1 CompositeConfig (alluxio.job.workflow.composite.CompositeConfig)1 Serializable (java.io.Serializable)1