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());
}
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));
}
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());
}
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));
}
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);
}
Aggregations