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