private List<Entry<Long, Integer>> passEventListToReader(final ListReader<IMonitoringRecord> reader) { long currentTimeSeconds; int curNumRecords = 0; final List<Entry<Long, Integer>> eventList = new ArrayList<>(this.eventTimeOffsetsSeconds.length); for (final long eventDelaySeconds : this.eventTimeOffsetsSeconds) { curNumRecords++; currentTimeSeconds = START_TIME_SECONDS + eventDelaySeconds; final Entry<Long, Integer> curEntry = new SimpleImmutableEntry<>(eventDelaySeconds, curNumRecords); eventList.add(curEntry); final EmptyRecord r = new EmptyRecord(); r.setLoggingTimestamp(TimeUnit.NANOSECONDS.convert(currentTimeSeconds, TimeUnit.SECONDS)); this.inputRecords.add(r); reader.addObject(r); } return eventList; }
/** * 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); }
/** * A simple test for the counting filter. * * @throws IllegalStateException * If the test setup is somehow invalid (should not happen). * @throws AnalysisConfigurationException * If the test setup is somehow invalid (should not happen). */ @Test public void testNormal() throws IllegalStateException, AnalysisConfigurationException { this.simpleListReader.addObject(new Object()); this.simpleListReader.addObject(new Object()); this.simpleListReader.addObject(new Object()); Assert.assertEquals(0, this.countingFilter.getMessageCount()); this.analysisController.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, this.analysisController.getState()); Assert.assertEquals(3, this.countingFilter.getMessageCount()); }
public ExecRecordTransformationFilterChecker(final List<OperationExecutionRecord> records) throws IllegalStateException, AnalysisConfigurationException { for (final OperationExecutionRecord record : records) { // the reader will provide these records via its output port this.listReader.addObject(record); } this.analysisController.connect(this.listReader, ListReader.OUTPUT_PORT_NAME, this.execRecFilter, ExecutionRecordTransformationFilter.INPUT_PORT_NAME_RECORDS); this.analysisController.connect(this.execRecFilter, ExecutionRecordTransformationFilter.OUTPUT_PORT_NAME_EXECUTIONS, this.sinkPlugin, ExecutionSinkClass.INPUT_PORT_NAME); this.analysisController.connect(this.execRecFilter, AbstractTraceAnalysisFilter.REPOSITORY_PORT_NAME_SYSTEM_MODEL, this.systemModelRepository); }
/** * A simple test for the counting filter using objects of different classes. * * @throws IllegalStateException * If the test setup is somehow invalid (should not happen). * @throws AnalysisConfigurationException * If the test setup is somehow invalid (should not happen). */ @Test public void testDifferentClasses() throws IllegalStateException, AnalysisConfigurationException { this.simpleListReader.addObject(Long.valueOf(10)); this.simpleListReader.addObject(null); this.simpleListReader.addObject(""); Assert.assertEquals(0, this.countingFilter.getMessageCount()); this.analysisController.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, this.analysisController.getState()); Assert.assertEquals(2, this.countingFilter.getMessageCount()); } }
/** * A test for the counting filter with multiple readers. * * @throws IllegalStateException * If the test setup is somehow invalid (should not happen). * @throws AnalysisConfigurationException * If the test setup is somehow invalid (should not happen). */ @Test public void testConcurrently() throws IllegalStateException, AnalysisConfigurationException { this.simpleListReader.addObject(new Object()); // register multiple readers (they fire concurrently) final ListReader<Object> reader2 = new ListReader<Object>(new Configuration(), this.analysisController); this.analysisController.connect(reader2, ListReader.OUTPUT_PORT_NAME, this.countingFilter, CountingFilter.INPUT_PORT_NAME_EVENTS); reader2.addObject(new Object()); final ListReader<Object> reader3 = new ListReader<Object>(new Configuration(), this.analysisController); this.analysisController.connect(reader3, ListReader.OUTPUT_PORT_NAME, this.countingFilter, CountingFilter.INPUT_PORT_NAME_EVENTS); reader3.addObject(new Object()); Assert.assertEquals(0, this.countingFilter.getMessageCount()); this.analysisController.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, this.analysisController.getState()); Assert.assertEquals(3, this.countingFilter.getMessageCount()); }
/** * 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()); }
/** * 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 an event <i>e</i> with <i>e.timestamp == a</i> does 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 testRecordOnLeftBorderPasses() throws IllegalStateException, AnalysisConfigurationException { final long leftBorder = TestTimestampFilter.EVENT.getTimestamp(); 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.assertFalse("Filter ignored event " + TestTimestampFilter.EVENT + " although timestamp on left Border " + leftBorder, this.sinkPlugin.getList().isEmpty()); Assert.assertTrue(this.sinkPlugin.getList().size() == 1); Assert.assertSame(this.sinkPlugin.getList().get(0), TestTimestampFilter.EVENT); }
/** * Given a {@link TimestampFilter} selecting {@link AbstractTraceEvent}s within an interval <i>[a,b]</i>, * assert that an event <i>e</i> with <i>e.timestamp == b</i> does 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 testRecordOnRightBorderPasses() throws IllegalStateException, AnalysisConfigurationException { final long rightBorder = TestTimestampFilter.EVENT.getTimestamp(); 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.assertFalse("Filter ignored event " + TestTimestampFilter.EVENT + " although timestamp on right Border " + rightBorder, this.sinkPlugin.getList().isEmpty()); Assert.assertTrue(this.sinkPlugin.getList().size() == 1); Assert.assertSame(this.sinkPlugin.getList().get(0), TestTimestampFilter.EVENT); }
private void runTestFailedInterleaved(final TraceEventRecords trace1, final TraceEventRecords trace2, final long maxTraceDuration, final long maxTraceTimeout) throws IllegalStateException, AnalysisConfigurationException { final IAnalysisController controller = new AnalysisController(); final ListReader<Object> reader = new ListReader<>(new Configuration(), controller); final Configuration configuration = new Configuration(); configuration.setProperty(EventRecordTraceReconstructionFilter.CONFIG_PROPERTY_NAME_MAX_TRACE_DURATION, Long.toString(maxTraceDuration)); configuration.setProperty(EventRecordTraceReconstructionFilter.CONFIG_PROPERTY_NAME_MAX_TRACE_TIMEOUT, Long.toString(maxTraceTimeout)); final EventRecordTraceReconstructionFilter traceFilter = new EventRecordTraceReconstructionFilter(configuration, controller); final ListCollectionFilter<TraceEventRecords> sinkPlugin = new ListCollectionFilter<>(new Configuration(), controller); Assert.assertTrue(sinkPlugin.getList().isEmpty()); final ListCollectionFilter<TraceEventRecords> sinkPluginFailed = new ListCollectionFilter<>(new Configuration(), controller); Assert.assertTrue(sinkPluginFailed.getList().isEmpty()); controller.connect(reader, ListReader.OUTPUT_PORT_NAME, traceFilter, EventRecordTraceReconstructionFilter.INPUT_PORT_NAME_TRACE_RECORDS); controller.connect(traceFilter, EventRecordTraceReconstructionFilter.OUTPUT_PORT_NAME_TRACE_VALID, sinkPlugin, ListCollectionFilter.INPUT_PORT_NAME); controller.connect(traceFilter, EventRecordTraceReconstructionFilter.OUTPUT_PORT_NAME_TRACE_INVALID, sinkPluginFailed, ListCollectionFilter.INPUT_PORT_NAME); reader.addObject(trace1.getTraceMetadata()); reader.addObject(trace2.getTraceMetadata()); final AbstractTraceEvent[] events1 = trace1.getTraceEvents(); final AbstractTraceEvent[] events2 = trace2.getTraceEvents(); for (int i = 0; i < events1.length; i++) { reader.addObject(events1[i]); reader.addObject(events2[i]); } controller.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, controller.getState()); // Make sure that only one of the two traces is generated Assert.assertEquals("There should be no trace", 1, sinkPlugin.getList().size()); }
/** * 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> and <i>r.timestamp * > a </i> does pass the filter. * * @throws AnalysisConfigurationException * If the internally assembled analysis configuration is somehow invalid. * @throws IllegalStateException * If the internally assembled analysis is in an invalid state. */ @Test public void testRecordTinToutWithinRangePassed() throws IllegalStateException, AnalysisConfigurationException { final long leftBorder = TestTimestampFilter.EVENT.getTimestamp() - 1; final long rightBorder = TestTimestampFilter.EVENT.getTimestamp() + 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.assertFalse("Filter ignored event " + TestTimestampFilter.EVENT + " although timestamp in interval [" + leftBorder + "," + rightBorder + "]", this.sinkPlugin.getList().isEmpty()); Assert.assertTrue(this.sinkPlugin.getList().size() == 1); Assert.assertSame(this.sinkPlugin.getList().get(0), TestTimestampFilter.EVENT); } }
private void runTestFailed(final TraceEventRecords records, final long maxTraceDuration, final long maxTraceTimeout) throws IllegalStateException, AnalysisConfigurationException { final IAnalysisController controller = new AnalysisController(); final ListReader<Object> reader = new ListReader<>(new Configuration(), controller); final Configuration configuration = new Configuration(); configuration.setProperty(EventRecordTraceReconstructionFilter.CONFIG_PROPERTY_NAME_MAX_TRACE_DURATION, Long.toString(maxTraceDuration)); configuration.setProperty(EventRecordTraceReconstructionFilter.CONFIG_PROPERTY_NAME_MAX_TRACE_TIMEOUT, Long.toString(maxTraceTimeout)); final EventRecordTraceReconstructionFilter traceFilter = new EventRecordTraceReconstructionFilter(configuration, controller); final ListCollectionFilter<TraceEventRecords> sinkPlugin = new ListCollectionFilter<>(new Configuration(), controller); Assert.assertTrue(sinkPlugin.getList().isEmpty()); controller.connect(reader, ListReader.OUTPUT_PORT_NAME, traceFilter, EventRecordTraceReconstructionFilter.INPUT_PORT_NAME_TRACE_RECORDS); controller.connect(traceFilter, EventRecordTraceReconstructionFilter.OUTPUT_PORT_NAME_TRACE_VALID, sinkPlugin, ListCollectionFilter.INPUT_PORT_NAME); reader.addObject(records.getTraceMetadata()); for (final AbstractTraceEvent e : records.getTraceEvents()) { reader.addObject(e); } controller.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, controller.getState()); // Make sure that no trace is generated Assert.assertEquals("There should be no trace", 0, sinkPlugin.getList().size()); }
simpleListReader.addObject(testObject1); simpleListReader.addObject(testObject2); final SimpleForwardFilterWithRepository simpleFilter = new SimpleForwardFilterWithRepository(new Configuration(), analysisController); final ListCollectionFilter<Object> simpleSinkPlugin = new ListCollectionFilter<Object>(new Configuration(), analysisController);
private void runTestEventBasedTraceRepair(final TraceEventRecords records, final long maxTraceDuration, final long maxTraceTimeout) throws IllegalStateException, AnalysisConfigurationException { final IAnalysisController controller = new AnalysisController(); final ListReader<Object> reader = new ListReader<>(new Configuration(), controller); final Configuration configuration = new Configuration(); configuration.setProperty(EventRecordTraceReconstructionFilter.CONFIG_PROPERTY_NAME_MAX_TRACE_DURATION, Long.toString(maxTraceDuration)); configuration.setProperty(EventRecordTraceReconstructionFilter.CONFIG_PROPERTY_NAME_MAX_TRACE_TIMEOUT, Long.toString(maxTraceTimeout)); configuration.setProperty(EventRecordTraceReconstructionFilter.CONFIG_PROPERTY_NAME_REPAIR_EVENT_BASED_TRACES, "true"); final EventRecordTraceReconstructionFilter traceFilter = new EventRecordTraceReconstructionFilter(configuration, controller); final ListCollectionFilter<TraceEventRecords> sinkPlugin = new ListCollectionFilter<>(new Configuration(), controller); Assert.assertTrue(sinkPlugin.getList().isEmpty()); controller.connect(reader, ListReader.OUTPUT_PORT_NAME, traceFilter, EventRecordTraceReconstructionFilter.INPUT_PORT_NAME_TRACE_RECORDS); controller.connect(traceFilter, EventRecordTraceReconstructionFilter.OUTPUT_PORT_NAME_TRACE_VALID, sinkPlugin, ListCollectionFilter.INPUT_PORT_NAME); reader.addObject(records.getTraceMetadata()); for (final AbstractTraceEvent e : records.getTraceEvents()) { reader.addObject(e); } controller.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, controller.getState()); Assert.assertEquals("No trace passed filter", 1, sinkPlugin.getList().size()); Assert.assertTrue("Repair failed", records.getTraceEvents().length < sinkPlugin.getList().get(0).getTraceEvents().length); Assert.assertEquals("Did not repair all BeforeEvents", sinkPlugin.getList().get(0).getTraceEvents().length, 10); }
@Ignore // NOCS @Test public void testRecordsWithStringEqualButNeverSame() throws IllegalStateException, AnalysisConfigurationException { final IAnalysisController 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); long timestamp = 3268936L; final IMonitoringRecord recordIn1 = TestStringBufferFilter.createOperationExecutionRecord(timestamp); timestamp++; final IMonitoringRecord recordIn2 = TestStringBufferFilter.createOperationExecutionRecord(timestamp); reader.addObject(recordIn1); reader.addObject(recordIn2); analysisController.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, analysisController.getState()); final List<IMonitoringRecord> records = collectionFilter.getList(); Assert.assertEquals("Unexpected number of records", 2, records.size()); final IMonitoringRecord recordOut1 = records.get(0); final IMonitoringRecord recordOut2 = records.get(1); Assert.assertNotSame("First output record same as first input record", recordIn1, recordOut1); // includes String, hence NOT "as-is" Assert.assertEquals("First output record doesn't equal first input record", recordIn1, recordOut1); // ... but must be equal Assert.assertNotSame("Second output record same as second input record", recordIn2, recordOut2); // includes String, hence NOT "as-is" Assert.assertEquals("Second output record doesn't equal second input record", recordIn2, recordOut2); // ... but must be equal }
reader.addObject(traceEvents);
@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" }