use of org.apache.metron.job.manager.InMemoryJobManager in project metron by apache.
the class PcapControllerIntegrationTest method setup.
@BeforeEach
public void setup() throws Exception {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).apply(springSecurity()).build();
InMemoryJobManager jobManager = (InMemoryJobManager) wac.getBean("jobManager");
jobManager.clear();
}
use of org.apache.metron.job.manager.InMemoryJobManager in project metron by apache.
the class PcapServiceImplTest method getRawShouldThrowException.
@Test
public void getRawShouldThrowException() throws Exception {
Path path = new Path("./target");
PcapServiceImpl pcapService = spy(new PcapServiceImpl(environment, configuration, new PcapJobSupplier(), new InMemoryJobManager<>(), pcapToPdmlScriptWrapper));
FileSystem fileSystem = mock(FileSystem.class);
doReturn(fileSystem).when(pcapService).getFileSystem();
when(fileSystem.exists(path)).thenReturn(true);
doReturn(path).when(pcapService).getPath("user", "jobId", 1);
when(fileSystem.open(path)).thenThrow(new IOException("some exception"));
RestException e = assertThrows(RestException.class, () -> pcapService.getRawPcap("user", "jobId", 1));
assertEquals("some exception", e.getMessage());
}
use of org.apache.metron.job.manager.InMemoryJobManager in project metron by apache.
the class PcapServiceImplTest method getPdmlShouldReturnNullOnNonexistentPath.
@Test
public void getPdmlShouldReturnNullOnNonexistentPath() throws Exception {
Path path = new Path("/some/path");
PcapServiceImpl pcapService = spy(new PcapServiceImpl(environment, configuration, new PcapJobSupplier(), new InMemoryJobManager<>(), pcapToPdmlScriptWrapper));
FileSystem fileSystem = mock(FileSystem.class);
doReturn(fileSystem).when(pcapService).getFileSystem();
when(fileSystem.exists(path)).thenReturn(false);
doReturn(path).when(pcapService).getPath("user", "jobId", 1);
assertNull(pcapService.getPdml("user", "jobId", 1));
}
use of org.apache.metron.job.manager.InMemoryJobManager in project metron by apache.
the class PcapServiceImplTest method getRawShouldReturnNullOnInvalidPage.
@Test
public void getRawShouldReturnNullOnInvalidPage() throws Exception {
Path path = new Path("/some/path");
PcapServiceImpl pcapService = spy(new PcapServiceImpl(environment, configuration, new PcapJobSupplier(), new InMemoryJobManager<>(), pcapToPdmlScriptWrapper));
FileSystem fileSystem = mock(FileSystem.class);
doReturn(fileSystem).when(pcapService).getFileSystem();
assertNull(pcapService.getRawPcap("user", "jobId", 1));
}
use of org.apache.metron.job.manager.InMemoryJobManager in project metron by apache.
the class PcapServiceImplTest method getConfigurationShouldProperlyReturnQueryFilterConfiguration.
@Test
public void getConfigurationShouldProperlyReturnQueryFilterConfiguration() throws Exception {
QueryPcapRequest queryPcapRequest = new QueryPcapRequest();
queryPcapRequest.setBasePath("basePath");
queryPcapRequest.setBaseInterimResultPath("baseOutputPath");
queryPcapRequest.setFinalOutputPath("finalOutputPath");
queryPcapRequest.setStartTimeMs(1L);
queryPcapRequest.setEndTimeMs(2L);
queryPcapRequest.setNumReducers(2);
queryPcapRequest.setQuery("query");
MockPcapJob mockPcapJob = new MockPcapJob();
mockPcapJobSupplier.setMockPcapJob(mockPcapJob);
JobManager jobManager = new InMemoryJobManager<>();
PcapServiceImpl pcapService = spy(new PcapServiceImpl(environment, configuration, mockPcapJobSupplier, jobManager, pcapToPdmlScriptWrapper));
FileSystem fileSystem = mock(FileSystem.class);
doReturn(fileSystem).when(pcapService).getFileSystem();
mockPcapJob.setStatus(new JobStatus().withJobId("jobId"));
pcapService.submit("user", queryPcapRequest);
Map<String, Object> configuration = pcapService.getConfiguration("user", "jobId");
assertEquals("basePath", configuration.get(PcapOptions.BASE_PATH.getKey()));
assertEquals("finalOutputPath", configuration.get(PcapOptions.FINAL_OUTPUT_PATH.getKey()));
assertEquals(1L, configuration.get(PcapOptions.START_TIME_MS.getKey()));
assertEquals(2L, configuration.get(PcapOptions.END_TIME_MS.getKey()));
assertEquals(2, configuration.get(PcapOptions.NUM_REDUCERS.getKey()));
assertEquals("query", configuration.get(QueryPcapOptions.QUERY.getKey()));
}
Aggregations