use of org.apache.metron.job.JobStatus in project metron by apache.
the class PcapJobTest method job_reports_percent_complete.
@Test
public void job_reports_percent_complete() throws Exception {
when(mrJob.isComplete()).thenReturn(false);
when(mrStatus.getState()).thenReturn(org.apache.hadoop.mapreduce.JobStatus.State.RUNNING);
when(mrJob.getStatus()).thenReturn(mrStatus);
when(mrJob.mapProgress()).thenReturn(0.5f);
when(mrJob.reduceProgress()).thenReturn(0f);
Statusable<Path> statusable = testJob.submit(finalizer, config);
timer.updateJobStatus();
JobStatus status = statusable.getStatus();
assertThat(status.getState(), equalTo(State.RUNNING));
assertThat(status.getDescription(), equalTo("map: 50.0%, reduce: 0.0%"));
assertThat(status.getPercentComplete(), equalTo(25.0 * 0.75));
when(mrJob.mapProgress()).thenReturn(1.0f);
when(mrJob.reduceProgress()).thenReturn(0.5f);
timer.updateJobStatus();
status = statusable.getStatus();
assertThat(status.getDescription(), equalTo("map: 100.0%, reduce: 50.0%"));
assertThat(status.getPercentComplete(), equalTo(75.0 * 0.75));
when(mrJob.mapProgress()).thenReturn(1.0f);
when(mrJob.reduceProgress()).thenReturn(1.0f);
timer.updateJobStatus();
status = statusable.getStatus();
assertThat(status.getDescription(), equalTo("map: 100.0%, reduce: 100.0%"));
assertThat(status.getPercentComplete(), equalTo(75.0));
when(mrJob.isComplete()).thenReturn(true);
when(mrStatus.getState()).thenReturn(org.apache.hadoop.mapreduce.JobStatus.State.SUCCEEDED);
when(mrJob.mapProgress()).thenReturn(1.0f);
when(mrJob.reduceProgress()).thenReturn(1.0f);
timer.updateJobStatus();
status = statusable.getStatus();
assertThat(status.getDescription(), equalTo("Job completed."));
assertThat(status.getPercentComplete(), equalTo(100.0));
}
Aggregations