/** * {@inheritDoc} */ @Override public int hashCode() { int code = 0; code += ((int)this.getTimestamp()); code += ((int)this.getTraceId()); code += ((int)this.getOrderIndex()); return code; }
/** * {@inheritDoc} */ @Override public boolean equals(final Object obj) { if (obj == null) return false; if (obj == this) return true; if (obj.getClass() != this.getClass()) return false; final AbstractTraceEvent castedRecord = (AbstractTraceEvent) obj; if (this.getLoggingTimestamp() != castedRecord.getLoggingTimestamp()) return false; if (this.getTimestamp() != castedRecord.getTimestamp()) return false; if (this.getTraceId() != castedRecord.getTraceId()) return false; if (this.getOrderIndex() != castedRecord.getOrderIndex()) return false; return true; }
return false; if (this.getTimestamp() != castedRecord.getTimestamp()) { return false;
@Test public void testTraceShorterThanMaxDurationPasses() throws IllegalStateException, AnalysisConfigurationException { final TraceEventRecords bookstoreTrace = BookstoreEventRecordFactory.validSyncTraceBeforeAfterEvents(START_TIME, TRACE_ID, SESSION_ID, HOSTNAME); Assert.assertEquals(TEST_INVALID, START_TIME, bookstoreTrace.getTraceEvents()[0].getTimestamp()); final long traceDuration = bookstoreTrace.getTraceEvents()[bookstoreTrace.getTraceEvents().length - 1].getTimestamp() - START_TIME; this.runTest(bookstoreTrace, traceDuration + 1, Long.MAX_VALUE); }
@Test public void testTraceLongerThanMaxDurationPasses() throws IllegalStateException, AnalysisConfigurationException { final TraceEventRecords bookstoreTrace = BookstoreEventRecordFactory.validSyncTraceBeforeAfterEvents(START_TIME, TRACE_ID, SESSION_ID, HOSTNAME); Assert.assertEquals(TEST_INVALID, START_TIME, bookstoreTrace.getTraceEvents()[0].getTimestamp()); final long traceDuration = bookstoreTrace.getTraceEvents()[bookstoreTrace.getTraceEvents().length - 1].getTimestamp() - START_TIME; this.runTestFailed(bookstoreTrace, traceDuration - 5, Long.MAX_VALUE); }
@Test public void testTraceShorterThanMaxTimeoutPasses() throws IllegalStateException, AnalysisConfigurationException { final TraceEventRecords bookstoreTrace = BookstoreEventRecordFactory.validSyncTraceBeforeAfterEvents(START_TIME, TRACE_ID, SESSION_ID, HOSTNAME); Assert.assertEquals(TEST_INVALID, START_TIME, bookstoreTrace.getTraceEvents()[0].getTimestamp()); this.runTest(bookstoreTrace, Long.MAX_VALUE, 100); }
@Test public void testEventBasedTraceRepairWithAfterEventAtEnd() throws IllegalStateException, AnalysisConfigurationException { final TraceEventRecords brokenTrace = this.brokenEventsWithAfterEventsAtEnd(START_TIME, TRACE_ID, SESSION_ID, HOSTNAME); Assert.assertEquals(TEST_INVALID, START_TIME, brokenTrace.getTraceEvents()[0].getTimestamp()); this.runTestEventBasedTraceRepair(brokenTrace, Long.MAX_VALUE, Long.MAX_VALUE); }
@Test public void testTraceMaxLong() throws IllegalStateException, AnalysisConfigurationException { final TraceEventRecords bookstoreTrace = BookstoreEventRecordFactory.validSyncTraceBeforeAfterEvents(START_TIME, TRACE_ID, SESSION_ID, HOSTNAME); Assert.assertEquals(TEST_INVALID, START_TIME, bookstoreTrace.getTraceEvents()[0].getTimestamp()); this.runTest(bookstoreTrace, Long.MAX_VALUE, Long.MAX_VALUE); }
@Test public void testEventBasedTraceRepairWithoutAnyAfterEvent() throws IllegalStateException, AnalysisConfigurationException { final TraceEventRecords brokenTrace = this.brokenEventsWithoutAfterEvents(START_TIME, TRACE_ID, SESSION_ID, HOSTNAME); Assert.assertEquals(TEST_INVALID, START_TIME, brokenTrace.getTraceEvents()[0].getTimestamp()); this.runTestEventBasedTraceRepair(brokenTrace, Long.MAX_VALUE, Long.MAX_VALUE); }
/** * 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); } }
@Test public void testTraceLongerThanMaxTimeoutPasses() throws IllegalStateException, AnalysisConfigurationException { final TraceEventRecords bookstoreTrace1 = BookstoreEventRecordFactory.validSyncTraceAdditionalCallEventsGap(START_TIME, TRACE_ID, SESSION_ID, HOSTNAME); final TraceEventRecords bookstoreTrace2 = BookstoreEventRecordFactory.validSyncTraceAdditionalCallEventsGap(START_TIME, TRACE_ID + 1, SESSION_ID, HOSTNAME); Assert.assertEquals(TEST_INVALID, START_TIME, bookstoreTrace1.getTraceEvents()[0].getTimestamp()); this.runTestFailedInterleaved(bookstoreTrace1, bookstoreTrace2, Long.MAX_VALUE, 1); }
/** * 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()); }
/** * 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); }
/** * 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. */ @Test public void testRecordTinToutWithinRangePassed() { final long leftBorder = TestTimestampFilter.EVENT.getTimestamp() - 1; final long rightBorder = TestTimestampFilter.EVENT.getTimestamp() + 1; final TimestampFilter timestampStage = new TimestampFilter(leftBorder, rightBorder); StageTester.test(timestampStage).and() .send(TestTimestampFilter.EVENT).to(timestampStage.getMonitoringRecordsCombinedInputPort()) .start(); Assert.assertThat(timestampStage.getRecordsWithinTimePeriodOutputPort(), StageTester.produces(TestTimestampFilter.EVENT)); Assert.assertThat(timestampStage.getRecordsOutsideTimePeriodOutputPort(), StageTester.producesNothing()); } }
/** * 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. */ @Test public void testRecordOnLeftBorderPasses() { final long leftBorder = TestTimestampFilter.EVENT.getTimestamp(); final long rightBorder = leftBorder + 1; final TimestampFilter timestampStage = new TimestampFilter(leftBorder, rightBorder); StageTester.test(timestampStage).and() .send(TestTimestampFilter.EVENT).to(timestampStage.getMonitoringRecordsCombinedInputPort()) .start(); Assert.assertThat(timestampStage.getRecordsWithinTimePeriodOutputPort(), StageTester.produces(TestTimestampFilter.EVENT)); Assert.assertThat(timestampStage.getRecordsOutsideTimePeriodOutputPort(), StageTester.producesNothing()); }
/** * 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. */ @Test public void testEventBeforeIgnored() { final long leftBorder = TestTimestampFilter.EVENT.getTimestamp() + 1; final long rightBorder = leftBorder + 1; final TimestampFilter timestampStage = new TimestampFilter(leftBorder, rightBorder); StageTester.test(timestampStage).and() .send(TestTimestampFilter.EVENT).to(timestampStage.getMonitoringRecordsCombinedInputPort()) .start(); Assert.assertThat(timestampStage.getRecordsWithinTimePeriodOutputPort(), StageTester.producesNothing()); Assert.assertThat(timestampStage.getRecordsOutsideTimePeriodOutputPort(), StageTester.produces(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. */ @Test public void testRecordOnRightBorderPasses() { final long rightBorder = TestTimestampFilter.EVENT.getTimestamp(); final long leftBorder = rightBorder - 1; final TimestampFilter timestampStage = new TimestampFilter(leftBorder, rightBorder); StageTester.test(timestampStage).and() .send(TestTimestampFilter.EVENT).to(timestampStage.getMonitoringRecordsCombinedInputPort()) .start(); Assert.assertThat(timestampStage.getRecordsWithinTimePeriodOutputPort(), StageTester.produces(TestTimestampFilter.EVENT)); Assert.assertThat(timestampStage.getRecordsOutsideTimePeriodOutputPort(), StageTester.producesNothing()); }
/** * 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. */ @Test public void testEventAfterIgnored() { final long rightBorder = TestTimestampFilter.EVENT.getTimestamp() - 1; final long leftBorder = rightBorder - 1; final TimestampFilter timestampStage = new TimestampFilter(leftBorder, rightBorder); StageTester.test(timestampStage) .and().send(TestTimestampFilter.EVENT).to(timestampStage.getMonitoringRecordsCombinedInputPort()) .start(); Assert.assertThat(timestampStage.getRecordsWithinTimePeriodOutputPort(), StageTester.producesNothing()); Assert.assertThat(timestampStage.getRecordsOutsideTimePeriodOutputPort(), StageTester.produces(TestTimestampFilter.EVENT)); }