@Override protected List<IMonitoringRecord> readEvents() throws AnalysisConfigurationException { return this.sinkFilter.getList(); } }
@Override protected List<IMonitoringRecord> readEvents() { return this.sinkFilter.getList(); } }
@Override protected List<IMonitoringRecord> readEvents() throws AnalysisConfigurationException { return this.sinkFilter.getList(); } }
@Override protected List<IMonitoringRecord> readEvents() throws AnalysisConfigurationException { return this.sinkFilter.getList(); } }
@Override protected List<IMonitoringRecord> readEvents() throws AnalysisConfigurationException { return this.sinkFilter.getList(); }
public List<IMonitoringRecord> getList() { return this.sinkPlugin.getList(); }
private void checkCorrectRelayedCount() { final List<Long> counts = this.sinkPluginRelayedRecords.getList(); final long count = counts.get(counts.size() - 1); Assert.assertEquals("Count should be 27 at the end of the test, but counted " + count, 27, count); }
private final void checkTiming() throws InterruptedException { final List<Long> throughput = this.sinkThroughput.getList(); final long[] actualArray = new long[throughput.size()]; for (int i = 0; i < actualArray.length; i++) { actualArray[i] = throughput.get(i); } Assert.assertArrayEquals("Unexpected throughput", actualArray, this.expectedThroughputListOffsetSecondsInterval5Secs); }
/** * Returns the result produced by this setup. Note that this method does not invoke {@link #run()} automatically. * * @return See above */ public List<T> getResult() { return this.getResultCollectionPlugin().getList(); }
private void checkCorrectUncountedCount() { final List<Long> counts = this.sinkPluginUncountedRecords.getList(); final long count = counts.get(0); Assert.assertEquals("Count should be 1 at the end of the test, but counted " + count, 1, count); } }
private final void checkRelayedRecords() { final List<EmptyRecord> relayedEvents = this.sinkPlugin.getList(); Assert.assertEquals(this.inputRecords, relayedEvents); }
private void checkCorrectCount() { final List<Long> counts = this.sinkPluginCount.getList(); final long firstCount = counts.get(0); // first count of interval Assert.assertEquals("First Count should be 10 at the end of the test, but counted " + firstCount, 10, firstCount); final long secondCount = counts.get(1); // second count of interval Assert.assertEquals("second Count should be 10 at the end of the test, but counted " + secondCount, 10, secondCount); final long thirdCount = counts.get(2); // second count of interval Assert.assertEquals("third Count should be 5 at the end of the test, but counted " + thirdCount, 5, thirdCount); }
/** * Converts the OperationExecutionRecord using the previously set up filter structure. * * @param oer * @throws IllegalStateException * exception that can possibly be thrown by AnalysisController * @throws AnalysisConfigurationException * exception that can possibly be thrown by AnalysisController */ private void convertRecord(final OperationExecutionRecord oer) throws IllegalStateException, AnalysisConfigurationException { this.simpleListReader.addObject(oer); this.analysisController.run(); this.conversionResult = this.listCollectionfilter.getList().get(0); }
/** * Test of the AnomalyDetectionFilter. * * @throws InterruptedException * If interrupted * @throws IllegalStateException * If illegal state * @throws AnalysisConfigurationException * If wrong configuration */ @Test public void testDetectionOnly() throws InterruptedException, IllegalStateException, AnalysisConfigurationException { final AnalysisControllerThread thread = new AnalysisControllerThread(this.controller); thread.start(); Thread.sleep(1000); thread.terminate(); Assert.assertEquals(2, this.sinkPluginIfAnomaly.getList().size()); Assert.assertEquals(1, this.sinkPluginElse.getList().size()); Assert.assertEquals(3, this.sinkPluginAll.getList().size()); }
/** * Starts a complete test flow through all currently available filters. In this case, the NamedDoubleRecords can * be from different applications and will still be treated correctly. * * @throws InterruptedException * If interrupted */ @Test public void testOpadFlow() throws InterruptedException { final AnalysisControllerThread thread = new AnalysisControllerThread(this.controller); thread.start(); Thread.sleep(2000); thread.terminate(); Assert.assertEquals(7, this.sinkPluginIfAnomaly.getList().size()); Assert.assertEquals(6, this.sinkPluginElse.getList().size()); }
/** * Test of the AnomalyScoreCalculationFilter. * * @throws InterruptedException * If interrupted * @throws IllegalStateException * If illegal state * @throws AnalysisConfigurationException * If wrong configuration */ @Test public void testAnomalyScoreCalculationOnly() throws InterruptedException, IllegalStateException, AnalysisConfigurationException { final AnalysisControllerThread thread = new AnalysisControllerThread(this.controller); thread.start(); Thread.sleep(1000); thread.terminate(); Assert.assertEquals(3, this.sinkAnomalyScore.getList().size()); Assert.assertEquals(this.sinkAnomalyScore.getList().get(0).getScore(), 0.19999999999999996, 0); Assert.assertEquals(this.sinkAnomalyScore.getList().get(1).getScore(), 0.1428571428571429, 0); Assert.assertEquals(this.sinkAnomalyScore.getList().get(2).getScore(), 0.0, 0); }
/** * Given a {@link TimestampFilter} selecting {@link AbstractTraceEvent}s within an interval <i>[a,b]</i>, * assert that a {@link AbstractTraceEvent} <i>e</i> with <i>e.timestamp > b </i> does not * pass the filter. * * @throws AnalysisConfigurationException * If the internally assembled analysis configuration is somehow invalid. * @throws IllegalStateException * If the internal analysis is in an invalid state. */ @Test public void testEventAfterIgnored() throws IllegalStateException, AnalysisConfigurationException { final long rightBorder = TestTimestampFilter.EVENT.getTimestamp() - 1; final long leftBorder = rightBorder - 1; this.createTimestampFilter(leftBorder, rightBorder); Assert.assertTrue(this.sinkPlugin.getList().isEmpty()); this.reader.addObject(TestTimestampFilter.EVENT); this.controller.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, this.controller.getState()); Assert.assertTrue("Filter passed event " + TestTimestampFilter.EVENT + " although timestamp before " + leftBorder, this.sinkPlugin.getList().isEmpty()); }
/** * Given a {@link TimestampFilter} selecting {@link AbstractTraceEvent}s within an interval <i>[a,b]</i>, * assert that a {@link AbstractTraceEvent} <i>e</i> with <i>e.timestamp < a</i> does not pass the filter. * * @throws AnalysisConfigurationException * If the internally assembled analysis configuration is somehow invalid. * @throws IllegalStateException * If the internal analysis is in an invalid state. */ @Test public void testEventBeforeIgnored() throws IllegalStateException, AnalysisConfigurationException { final long leftBorder = TestTimestampFilter.EVENT.getTimestamp() + 1; final long rightBorder = leftBorder + 1; this.createTimestampFilter(leftBorder, rightBorder); Assert.assertTrue(this.sinkPlugin.getList().isEmpty()); this.reader.addObject(TestTimestampFilter.EVENT); this.controller.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, this.controller.getState()); Assert.assertTrue("Filter passed event " + TestTimestampFilter.EVENT + " although timestamp before " + leftBorder, this.sinkPlugin.getList().isEmpty()); }
@Ignore // NOCS @Test public void testRecordsWithoutStringSame() throws IllegalStateException, AnalysisConfigurationException { final AnalysisController analysisController = new AnalysisController(); final ListReader<IMonitoringRecord> reader = new ListReader<>(new Configuration(), analysisController); final StringBufferFilter stringBufferFilter = new StringBufferFilter(new Configuration(), analysisController); final ListCollectionFilter<IMonitoringRecord> collectionFilter = new ListCollectionFilter<>(new Configuration(), analysisController); analysisController.connect(reader, ListReader.OUTPUT_PORT_NAME, stringBufferFilter, StringBufferFilter.INPUT_PORT_NAME_EVENTS); analysisController.connect(stringBufferFilter, StringBufferFilter.OUTPUT_PORT_NAME_RELAYED_EVENTS, collectionFilter, ListCollectionFilter.INPUT_PORT_NAME); final IMonitoringRecord recordIn1 = new EmptyRecord(); reader.addObject(recordIn1); analysisController.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, analysisController.getState()); final List<IMonitoringRecord> records = collectionFilter.getList(); Assert.assertEquals("Unexpected number of records", 1, records.size()); final IMonitoringRecord recordOut1 = records.get(0); Assert.assertSame("First output record not same as first input record", recordIn1, recordOut1); // includes no String, hence "as-is" }
private List<IMonitoringRecord> readLog(final String[] monitoringLogDirs) throws AnalysisConfigurationException { final AnalysisController analysisController = new AnalysisController(); final Configuration readerConfiguration = new Configuration(); readerConfiguration.setProperty(AsciiLogReader.CONFIG_PROPERTY_NAME_INPUTDIRS, Configuration.toProperty(monitoringLogDirs)); readerConfiguration.setProperty(AsciiLogReader.CONFIG_PROPERTY_NAME_IGNORE_UNKNOWN_RECORD_TYPES, "false"); final AbstractReaderPlugin reader = new AsciiLogReader(readerConfiguration, analysisController); final ListCollectionFilter<IMonitoringRecord> sinkPlugin = new ListCollectionFilter<>(new Configuration(), analysisController); analysisController.connect(reader, AsciiLogReader.OUTPUT_PORT_NAME_RECORDS, sinkPlugin, ListCollectionFilter.INPUT_PORT_NAME); analysisController.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, analysisController.getState()); return sinkPlugin.getList(); } }