use of com.alibaba.datax.core.job.scheduler.processinner.ProcessInnerScheduler in project DataX by alibaba.
the class StandAloneSchedulerTest method testSchedule.
@Test
public void testSchedule() throws NoSuchFieldException, IllegalAccessException {
int taskNumber = 10;
List<Configuration> jobList = new ArrayList<Configuration>();
List<Configuration> internal = new ArrayList<Configuration>();
int randomSize = 20;
int length = RandomUtils.nextInt(0, randomSize) + 1;
for (int i = 0; i < length; i++) {
internal.add(Configuration.newDefault());
}
LocalTGCommunicationManager.clear();
for (int i = 0; i < taskNumber; i++) {
Configuration configuration = Configuration.newDefault();
configuration.set(CoreConstant.DATAX_CORE_CONTAINER_JOB_REPORTINTERVAL, 11);
configuration.set(CoreConstant.DATAX_CORE_CONTAINER_JOB_ID, 0);
configuration.set(CoreConstant.DATAX_JOB_CONTENT, internal);
configuration.set(CoreConstant.DATAX_CORE_CONTAINER_JOB_MODE, ExecuteMode.STANDALONE.getValue());
configuration.set(CoreConstant.DATAX_CORE_CONTAINER_TASKGROUP_ID, i);
jobList.add(configuration);
LocalTGCommunicationManager.registerTaskGroupCommunication(i, new Communication());
}
StandAloneJobContainerCommunicator standAloneJobContainerCommunicator = PowerMockito.mock(StandAloneJobContainerCommunicator.class);
ProcessInnerScheduler scheduler = PowerMockito.spy(new StandAloneScheduler(standAloneJobContainerCommunicator));
PowerMockito.doNothing().when(scheduler).startAllTaskGroup(anyListOf(Configuration.class));
Communication communication = new Communication();
communication.setState(State.SUCCEEDED);
PowerMockito.when(standAloneJobContainerCommunicator.collect()).thenReturn(communication);
PowerMockito.doNothing().when(standAloneJobContainerCommunicator).report(communication);
scheduler.schedule(jobList);
}
Aggregations