use of org.graylog2.plugin.inputs.Extractor.Result in project graylog2-server by Graylog2.
the class SearchesTest method fieldStatsRecordsMetrics.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void fieldStatsRecordsMetrics() throws Exception {
FieldStatsResult result = searches.fieldStats("n", "*", AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC)));
assertThat(metricRegistry.getTimers()).containsKey(REQUEST_TIMER_NAME);
assertThat(metricRegistry.getHistograms()).containsKey(RANGES_HISTOGRAM_NAME);
Timer timer = metricRegistry.timer(REQUEST_TIMER_NAME);
assertThat(timer.getCount()).isEqualTo(1L);
Histogram histogram = metricRegistry.histogram(RANGES_HISTOGRAM_NAME);
assertThat(histogram.getCount()).isEqualTo(1L);
assertThat(histogram.getSnapshot().getValues()).containsExactly(86400L);
}
use of org.graylog2.plugin.inputs.Extractor.Result in project graylog2-server by Graylog2.
the class SearchesTest method termsRecordsMetrics.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void termsRecordsMetrics() throws Exception {
TermsResult result = searches.terms("n", 25, "*", AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC)));
assertThat(metricRegistry.getTimers()).containsKey(REQUEST_TIMER_NAME);
assertThat(metricRegistry.getHistograms()).containsKey(RANGES_HISTOGRAM_NAME);
Timer timer = metricRegistry.timer(REQUEST_TIMER_NAME);
assertThat(timer.getCount()).isEqualTo(1L);
Histogram histogram = metricRegistry.histogram(RANGES_HISTOGRAM_NAME);
assertThat(histogram.getCount()).isEqualTo(1L);
assertThat(histogram.getSnapshot().getValues()).containsExactly(86400L);
}
use of org.graylog2.plugin.inputs.Extractor.Result in project graylog2-server by Graylog2.
the class StreamRouterEngineTest method testAndStreamWithMultipleRules.
@Test
public void testAndStreamWithMultipleRules() {
final String dummyField = "dummyField";
final String dummyValue = "dummyValue";
final StreamRule streamRule1 = getStreamRuleMock("StreamRule1Id", StreamRuleType.EXACT, dummyField, dummyValue);
final StreamRule streamRule2 = getStreamRuleMock("StreamRule2Id", StreamRuleType.EXACT, dummyField, dummyValue);
final Stream stream = mock(Stream.class);
when(stream.getId()).thenReturn("Stream1Id");
when(stream.getMatchingType()).thenReturn(Stream.MatchingType.OR);
when(stream.getStreamRules()).thenReturn(Lists.newArrayList(streamRule1, streamRule2));
final Message message = mock(Message.class);
when(message.getField(eq(dummyField))).thenReturn(dummyValue);
final StreamRouterEngine engine = newEngine(Lists.newArrayList(stream));
final List<Stream> result = engine.match(message);
assertThat(result).hasSize(1);
assertThat(result).contains(stream);
}
use of org.graylog2.plugin.inputs.Extractor.Result in project graylog2-server by Graylog2.
the class StreamRouterEngineTest method testOrMatching.
@Test
public void testOrMatching() {
final String dummyField = "dummyField";
final String dummyValue = "dummyValue";
final Stream stream = mock(Stream.class);
when(stream.getMatchingType()).thenReturn(Stream.MatchingType.OR);
final StreamRule streamRule1 = getStreamRuleMock("StreamRule1Id", StreamRuleType.EXACT, dummyField, dummyValue);
final StreamRule streamRule2 = getStreamRuleMock("StreamRule2Id", StreamRuleType.EXACT, dummyField, "not" + dummyValue);
when(stream.getStreamRules()).thenReturn(Lists.newArrayList(streamRule1, streamRule2));
final Message message = mock(Message.class);
when(message.getField(eq(dummyField))).thenReturn(dummyValue);
final StreamRouterEngine engine = newEngine(Lists.newArrayList(stream));
final List<Stream> result = engine.match(message);
assertThat(result).hasSize(1);
assertThat(result).contains(stream);
}
use of org.graylog2.plugin.inputs.Extractor.Result in project graylog2-server by Graylog2.
the class StreamRouterEngineTest method getStreamRuleMock.
private StreamRule getStreamRuleMock(String id, StreamRuleType type, String field, String value) {
final StreamRule result = mock(StreamRule.class);
when(result.getId()).thenReturn(id);
when(result.getType()).thenReturn(type);
when(result.getField()).thenReturn(field);
when(result.getValue()).thenReturn(value);
return result;
}
Aggregations