* @return void
*/
public void testRetiredJobsSuccessful() throws Exception {
Configuration conf = new Configuration(cluster.getConf());
conf.setBoolean("mapreduce.job.complete.cancel.delegation.tokens", false);
JTProtocol remoteJTClient = cluster.getJTClient().getProxy();
int testLoopCount = 0;
//First run a successful job and verify if JobInProgress
//object is removed by checking the getJobInfo. In the
//second iteration, verify if a killed job JobInProgress
//is removed.
do {
testLoopCount++;
SleepJob job = new SleepJob();
job.setConf(conf);
conf = job.setupJobConf(5, 1, 100, 100, 100, 100);
//Get the value of mapred.jobtracker.retirejob.check. If not
//found then use 60000 milliseconds, which is the application default.
retiredJobInterval =
conf.getInt("mapred.jobtracker.retirejob.check", 60000);
//Assert if retiredJobInterval is 0
if ( retiredJobInterval == 0 ) {
Assert.fail("mapred.jobtracker.retirejob.check is 0");
}
JobConf jconf = new JobConf(conf);
//Controls the job till all verification is done
FinishTaskControlAction.configureControlActionForJob(conf);
//Submitting the job
RunningJob rJob = cluster.getJTClient().getClient().submitJob(jconf);
JobID jobID = rJob.getID();
JobInfo jInfo = remoteJTClient.getJobInfo(jobID);
LOG.info("jInfo is :" + jInfo);
boolean jobStarted = cluster.getJTClient().isJobStarted(jobID);
Assert.assertTrue("Job has not started even after a minute",
jobStarted );
LOG.info("job id is :" + jobID.toString());
TaskInfo[] taskInfos = cluster.getJTClient().getProxy()
.getTaskInfo(jobID);
// getJobInfo method should
// return a JobInProgress object when running,
JobInfo jobInfo = cluster.getJTClient().getProxy()
.getJobInfo(jobID);
Assert.assertNotNull("The Job information is not present ", jobInfo);
//Allow the job to continue through MR control job.
for (TaskInfo taskInfoRemaining : taskInfos) {
FinishTaskControlAction action = new FinishTaskControlAction(TaskID
.downgrade(taskInfoRemaining.getTaskID()));
Collection<TTClient> tts = cluster.getTTClients();
for (TTClient cli : tts) {
cli.getProxy().sendAction(action);
}
}
//Killing this job will happen only in the second iteration.
if (testLoopCount == 2) {
//Killing the job because all the verification needed
//for this testcase is completed.
rJob.killJob();
}
//Making sure that the job is complete.
int count = 0;
while (jInfo != null && !jInfo.getStatus().isJobComplete()) {
UtilsForTests.waitFor(10000);
count++;
jInfo = remoteJTClient.getJobInfo(rJob.getID());
//If the count goes more than 100 seconds, then fail; This is to
//avoid infinite loop
if (count > 10) {
Assert.fail("Since the job has not completed even after" +
" 100 seconds, failing at this point");