use of org.apache.metron.job.JobStatus in project metron by apache.
the class PcapJobTest method killing_job_causes_status_to_return_KILLED_state.
@Test
public void killing_job_causes_status_to_return_KILLED_state() throws Exception {
when(mrJob.isComplete()).thenReturn(false);
when(mrStatus.getState()).thenReturn(org.apache.hadoop.mapreduce.JobStatus.State.RUNNING);
when(mrJob.getStatus()).thenReturn(mrStatus);
Statusable<Path> statusable = testJob.submit(finalizer, config);
statusable.kill();
when(mrJob.isComplete()).thenReturn(true);
when(mrStatus.getState()).thenReturn(org.apache.hadoop.mapreduce.JobStatus.State.KILLED);
timer.updateJobStatus();
JobStatus status = statusable.getStatus();
assertThat(status.getState(), equalTo(State.KILLED));
}
use of org.apache.metron.job.JobStatus in project metron by apache.
the class PcapJobTest method job_succeeds_synchronously.
@Test
public void job_succeeds_synchronously() throws Exception {
pageableResult = new PcapPages(Arrays.asList(new Path("1.txt"), new Path("2.txt"), new Path("3.txt")));
when(finalizer.finalizeJob(any())).thenReturn(pageableResult);
when(mrJob.isComplete()).thenReturn(true);
when(mrStatus.getState()).thenReturn(org.apache.hadoop.mapreduce.JobStatus.State.SUCCEEDED);
when(mrJob.getStatus()).thenReturn(mrStatus);
Statusable<Path> statusable = testJob.submit(finalizer, config);
timer.updateJobStatus();
Pageable<Path> results = statusable.get();
assertThat(results.getSize(), equalTo(3));
JobStatus status = statusable.getStatus();
assertThat(status.getState(), equalTo(State.SUCCEEDED));
assertThat(status.getPercentComplete(), equalTo(100.0));
assertThat(status.getJobId(), equalTo(jobIdVal));
}
use of org.apache.metron.job.JobStatus in project metron by apache.
the class PcapJobTest method handles_null_values_with_defaults.
@Test
public void handles_null_values_with_defaults() throws Exception {
PcapOptions.START_TIME_NS.put(config, null);
PcapOptions.END_TIME_NS.put(config, null);
PcapOptions.NUM_REDUCERS.put(config, null);
PcapOptions.NUM_RECORDS_PER_FILE.put(config, null);
pageableResult = new PcapPages(Arrays.asList(new Path("1.txt"), new Path("2.txt"), new Path("3.txt")));
when(finalizer.finalizeJob(any())).thenReturn(pageableResult);
when(mrJob.isComplete()).thenReturn(true);
when(mrStatus.getState()).thenReturn(org.apache.hadoop.mapreduce.JobStatus.State.SUCCEEDED);
when(mrJob.getStatus()).thenReturn(mrStatus);
Statusable<Path> statusable = testJob.submit(finalizer, config);
timer.updateJobStatus();
Pageable<Path> results = statusable.get();
assertThat(results.getSize(), equalTo(3));
JobStatus status = statusable.getStatus();
assertThat(status.getState(), equalTo(State.SUCCEEDED));
assertThat(status.getPercentComplete(), equalTo(100.0));
assertThat(status.getJobId(), equalTo(jobIdVal));
}
use of org.apache.metron.job.JobStatus in project metron by apache.
the class PcapJobTest method job_succeeds_asynchronously.
@Test
public void job_succeeds_asynchronously() throws Exception {
when(mrJob.isComplete()).thenReturn(true);
when(mrStatus.getState()).thenReturn(org.apache.hadoop.mapreduce.JobStatus.State.SUCCEEDED);
when(mrJob.getStatus()).thenReturn(mrStatus);
Statusable<Path> statusable = testJob.submit(finalizer, config);
timer.updateJobStatus();
JobStatus status = statusable.getStatus();
assertThat(status.getState(), equalTo(State.SUCCEEDED));
assertThat(status.getPercentComplete(), equalTo(100.0));
}
use of org.apache.metron.job.JobStatus in project metron by apache.
the class PcapJobTest method job_fails_with_killed_status_synchronously.
@Test
public void job_fails_with_killed_status_synchronously() throws Exception {
when(mrJob.isComplete()).thenReturn(true);
when(mrStatus.getState()).thenReturn(org.apache.hadoop.mapreduce.JobStatus.State.KILLED);
when(mrJob.getStatus()).thenReturn(mrStatus);
Statusable<Path> statusable = testJob.submit(finalizer, config);
timer.updateJobStatus();
Pageable<Path> results = statusable.get();
JobStatus status = statusable.getStatus();
assertThat(status.getState(), equalTo(State.KILLED));
assertThat(status.getPercentComplete(), equalTo(100.0));
assertThat(results.getSize(), equalTo(0));
}
Aggregations