// Launch a map-only job
pigServer.registerQuery("A = load '" + inputFile + "' as (id:int, fruit:chararray);");
pigServer.registerQuery("store A into 'task_reports';");
List<ExecJob> jobs = pigServer.executeBatch();
PigStats pigStats = jobs.get(0).getStatistics();
MRJobStats jobStats = (MRJobStats) pigStats.getJobGraph().getJobList().get(0);
// Make sure JobStats includes TaskReports information
long minMapTime = jobStats.getMinMapTime();
long maxMapTime = jobStats.getMaxMapTime();
long avgMapTime = jobStats.getAvgMapTime();
assertTrue("TaskReports are enabled, so minMapTime shouldn't be -1", minMapTime != -1l);
assertTrue("TaskReports are enabled, so maxMapTime shouldn't be -1", maxMapTime != -1l);
assertTrue("TaskReports are enabled, so avgMapTime shouldn't be -1", avgMapTime != -1l);
// Disable task reports in job statistics
properties.setProperty(PigConfiguration.PIG_NO_TASK_REPORT, "true");
// Launch another map-only job
pigServer.registerQuery("B = load '" + inputFile + "' as (id:int, fruit:chararray);");
pigServer.registerQuery("store B into 'no_task_reports';");
jobs = pigServer.executeBatch();
pigStats = jobs.get(0).getStatistics();
jobStats = (MRJobStats) pigStats.getJobGraph().getJobList().get(0);
// Make sure JobStats doesn't include any TaskReports information
minMapTime = jobStats.getMinMapTime();
maxMapTime = jobStats.getMaxMapTime();
avgMapTime = jobStats.getAvgMapTime();
assertEquals("TaskReports are disabled, so minMapTime should be -1", -1l, minMapTime);
assertEquals("TaskReports are disabled, so maxMapTime should be -1", -1l, maxMapTime);
assertEquals("TaskReports are disabled, so avgMapTime should be -1", -1l, avgMapTime);
cluster.shutDown();