Search in sources :

Example 1 with JobStatus

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));
}
Also used : Path(org.apache.hadoop.fs.Path) JobStatus(org.apache.metron.job.JobStatus) Test(org.junit.jupiter.api.Test)

Example 2 with JobStatus

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));
}
Also used : Path(org.apache.hadoop.fs.Path) JobStatus(org.apache.metron.job.JobStatus) PcapPages(org.apache.metron.pcap.PcapPages) Test(org.junit.jupiter.api.Test)

Example 3 with JobStatus

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));
}
Also used : Path(org.apache.hadoop.fs.Path) JobStatus(org.apache.metron.job.JobStatus) PcapPages(org.apache.metron.pcap.PcapPages) Test(org.junit.jupiter.api.Test)

Example 4 with JobStatus

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));
}
Also used : Path(org.apache.hadoop.fs.Path) JobStatus(org.apache.metron.job.JobStatus) Test(org.junit.jupiter.api.Test)

Example 5 with JobStatus

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));
}
Also used : Path(org.apache.hadoop.fs.Path) JobStatus(org.apache.metron.job.JobStatus) Test(org.junit.jupiter.api.Test)

Aggregations

JobStatus (org.apache.metron.job.JobStatus)21 Test (org.junit.jupiter.api.Test)18 MockPcapJob (org.apache.metron.rest.mock.MockPcapJob)11 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11 Path (org.apache.hadoop.fs.Path)10 PcapPages (org.apache.metron.pcap.PcapPages)5 IOException (java.io.IOException)3 JobException (org.apache.metron.job.JobException)3 FixedPcapFilter (org.apache.metron.pcap.filter.fixed.FixedPcapFilter)2 File (java.io.File)1 QueryPcapFilter (org.apache.metron.pcap.filter.query.QueryPcapFilter)1 RestException (org.apache.metron.rest.RestException)1 PcapStatus (org.apache.metron.rest.model.pcap.PcapStatus)1