Search in sources :

Example 6 with TestPlanConfig

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

the class JobMasterTest method list.

@Test
public void list() 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 7 with TestPlanConfig

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

the class PlanInfoTest method compare.

@Test
public void compare() {
    JobConfig jobConfig = new TestPlanConfig("unused");
    PlanInfo a = new PlanInfo(0L, jobConfig, null);
    CommonUtils.sleepMs(1);
    PlanInfo b = new PlanInfo(0L, jobConfig, null);
    Assert.assertEquals(-1, a.compareTo(b));
    b.setStatus(Status.RUNNING);
    CommonUtils.sleepMs(1);
    a.setStatus(Status.RUNNING);
    Assert.assertEquals(1, a.compareTo(b));
    a.setStatus(Status.COMPLETED);
    CommonUtils.sleepMs(1);
    b.setStatus(Status.COMPLETED);
    Assert.assertEquals(-1, a.compareTo(b));
}
Also used : TestPlanConfig(alluxio.job.TestPlanConfig) PlanInfo(alluxio.job.plan.meta.PlanInfo) JobConfig(alluxio.job.JobConfig) Test(org.junit.Test)

Example 8 with TestPlanConfig

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

the class PlanInfoTest method callback.

@Test
public void callback() {
    final String result = "I was here!";
    JobConfig jobConfig = new TestPlanConfig("unused");
    PlanInfo a = new PlanInfo(0L, jobConfig, jobInfo -> jobInfo.setResult(result));
    a.setStatus(Status.COMPLETED);
    Assert.assertEquals(result, a.getResult());
}
Also used : TestPlanConfig(alluxio.job.TestPlanConfig) PlanInfo(alluxio.job.plan.meta.PlanInfo) JobConfig(alluxio.job.JobConfig) Test(org.junit.Test)

Example 9 with TestPlanConfig

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

the class CommandHandlingExecutorTest method heartbeat.

@Test
public void heartbeat() throws Exception {
    JobCommand.Builder command = JobCommand.newBuilder();
    RunTaskCommand.Builder runTaskCommand = RunTaskCommand.newBuilder();
    long jobId = 1;
    runTaskCommand.setJobId(jobId);
    long taskId = 2;
    runTaskCommand.setTaskId(taskId);
    JobConfig jobConfig = new TestPlanConfig("/test");
    runTaskCommand.setJobConfig(ByteString.copyFrom(SerializationUtils.serialize(jobConfig)));
    Serializable taskArgs = Lists.newArrayList(1);
    runTaskCommand.setTaskArgs(ByteString.copyFrom(SerializationUtils.serialize(taskArgs)));
    command.setRunTaskCommand(runTaskCommand);
    Mockito.when(mJobMasterClient.heartbeat(any(JobWorkerHealth.class), eq(Lists.newArrayList()))).thenReturn(Lists.newArrayList(command.build()));
    mCommandHandlingExecutor.heartbeat();
    ExecutorService executorService = Whitebox.getInternalState(mCommandHandlingExecutor, "mCommandHandlingService");
    executorService.shutdown();
    Assert.assertTrue(executorService.awaitTermination(5000, TimeUnit.MILLISECONDS));
    Mockito.verify(mTaskExecutorManager).getAndClearTaskUpdates();
    Mockito.verify(mTaskExecutorManager).executeTask(Mockito.eq(jobId), Mockito.eq(taskId), Mockito.eq(runTaskCommand.build()), Mockito.any(RunTaskContext.class));
}
Also used : RunTaskCommand(alluxio.grpc.RunTaskCommand) TestPlanConfig(alluxio.job.TestPlanConfig) Serializable(java.io.Serializable) RunTaskContext(alluxio.job.RunTaskContext) JobCommand(alluxio.grpc.JobCommand) ExecutorService(java.util.concurrent.ExecutorService) JobWorkerHealth(alluxio.job.wire.JobWorkerHealth) JobConfig(alluxio.job.JobConfig) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 10 with TestPlanConfig

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

the class PlanDefinitionRegistryTest method getPlanDefinitionTest.

@Test
public void getPlanDefinitionTest() throws Exception {
    PlanDefinition<TestPlanConfig, ?, ?> definition = PlanDefinitionRegistry.INSTANCE.getJobDefinition(new TestPlanConfig("test"));
    Assert.assertTrue(definition instanceof TestPlanDefinition);
}
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