use of org.graylog2.plugin.indexer.searches.timeranges.RelativeRange in project graylog2-server by Graylog2.
the class SearchesTest method determineAffectedIndicesIncludesDeflectorTarget.
@Test
public void determineAffectedIndicesIncludesDeflectorTarget() throws Exception {
final DateTime now = DateTime.now(DateTimeZone.UTC);
final MongoIndexRange indexRange0 = MongoIndexRange.create("graylog_0", now, now.plusDays(1), now, 0);
final MongoIndexRange indexRange1 = MongoIndexRange.create("graylog_1", now.plusDays(1), now.plusDays(2), now, 0);
final MongoIndexRange indexRangeLatest = MongoIndexRange.create("graylog_2", new DateTime(0L, DateTimeZone.UTC), new DateTime(0L, DateTimeZone.UTC), now, 0);
final SortedSet<IndexRange> indices = ImmutableSortedSet.orderedBy(IndexRange.COMPARATOR).add(indexRange0).add(indexRange1).add(indexRangeLatest).build();
when(indexRangeService.find(any(DateTime.class), any(DateTime.class))).thenReturn(indices);
final TimeRange absoluteRange = AbsoluteRange.create(now.minusDays(1), now.plusDays(1));
final TimeRange keywordRange = KeywordRange.create("1 day ago");
final TimeRange relativeRange = RelativeRange.create(3600);
assertThat(searches.determineAffectedIndices(absoluteRange, null)).containsExactlyInAnyOrder(indexRangeLatest.indexName(), indexRange0.indexName(), indexRange1.indexName());
assertThat(searches.determineAffectedIndices(keywordRange, null)).containsExactlyInAnyOrder(indexRangeLatest.indexName(), indexRange0.indexName(), indexRange1.indexName());
assertThat(searches.determineAffectedIndices(relativeRange, null)).containsExactlyInAnyOrder(indexRangeLatest.indexName(), indexRange0.indexName(), indexRange1.indexName());
}
use of org.graylog2.plugin.indexer.searches.timeranges.RelativeRange in project graylog2-server by Graylog2.
the class ValueReferenceTypeIdResolverTest method testSerialization.
@Test
public void testSerialization() throws IOException, InvalidRangeParametersException {
final RelativeRangeEntity relativeRange = RelativeRangeEntity.of(RelativeRange.create(300));
final String json = objectMapper.writeValueAsString(relativeRange);
assertThat(json).isNotNull();
}
use of org.graylog2.plugin.indexer.searches.timeranges.RelativeRange in project graylog2-server by Graylog2.
the class SearchesIT method determineAffectedIndicesWithRangesIncludesDeflectorTarget.
@Test
public void determineAffectedIndicesWithRangesIncludesDeflectorTarget() throws Exception {
final DateTime now = DateTime.now(DateTimeZone.UTC);
final MongoIndexRange indexRange0 = MongoIndexRange.create("graylog_0", now, now.plusDays(1), now, 0);
final MongoIndexRange indexRange1 = MongoIndexRange.create("graylog_1", now.plusDays(1), now.plusDays(2), now, 0);
final MongoIndexRange indexRangeLatest = MongoIndexRange.create("graylog_2", new DateTime(0L, DateTimeZone.UTC), new DateTime(0L, DateTimeZone.UTC), now, 0);
final SortedSet<IndexRange> indices = ImmutableSortedSet.orderedBy(IndexRange.COMPARATOR).add(indexRange0).add(indexRange1).add(indexRangeLatest).build();
when(indexRangeService.find(any(DateTime.class), any(DateTime.class))).thenReturn(indices);
final TimeRange absoluteRange = AbsoluteRange.create(now.minusDays(1), now.plusDays(1));
final TimeRange keywordRange = KeywordRange.create("1 day ago", "Etc/UTC");
final TimeRange relativeRange = RelativeRange.create(3600);
assertThat(searches.determineAffectedIndicesWithRanges(absoluteRange, null)).containsExactly(indexRangeLatest, indexRange0, indexRange1);
assertThat(searches.determineAffectedIndicesWithRanges(keywordRange, null)).containsExactly(indexRangeLatest, indexRange0, indexRange1);
assertThat(searches.determineAffectedIndicesWithRanges(relativeRange, null)).containsExactly(indexRangeLatest, indexRange0, indexRange1);
}
use of org.graylog2.plugin.indexer.searches.timeranges.RelativeRange in project graylog2-server by Graylog2.
the class SearchesIT method determineAffectedIndicesWithRangesDoesNotIncludesDeflectorTargetIfMissing.
@Test
public void determineAffectedIndicesWithRangesDoesNotIncludesDeflectorTargetIfMissing() throws Exception {
final DateTime now = DateTime.now(DateTimeZone.UTC);
final MongoIndexRange indexRange0 = MongoIndexRange.create("graylog_0", now, now.plusDays(1), now, 0);
final MongoIndexRange indexRange1 = MongoIndexRange.create("graylog_1", now.plusDays(1), now.plusDays(2), now, 0);
final SortedSet<IndexRange> indices = ImmutableSortedSet.orderedBy(IndexRange.COMPARATOR).add(indexRange0).add(indexRange1).build();
when(indexRangeService.find(any(DateTime.class), any(DateTime.class))).thenReturn(indices);
final TimeRange absoluteRange = AbsoluteRange.create(now.minusDays(1), now.plusDays(1));
final TimeRange keywordRange = KeywordRange.create("1 day ago", "Etc/UTC");
final TimeRange relativeRange = RelativeRange.create(3600);
assertThat(searches.determineAffectedIndicesWithRanges(absoluteRange, null)).containsExactly(indexRange0, indexRange1);
assertThat(searches.determineAffectedIndicesWithRanges(keywordRange, null)).containsExactly(indexRange0, indexRange1);
assertThat(searches.determineAffectedIndicesWithRanges(relativeRange, null)).containsExactly(indexRange0, indexRange1);
}
use of org.graylog2.plugin.indexer.searches.timeranges.RelativeRange in project graylog2-server by Graylog2.
the class DerivedTimeRangeTest method returnsInitialRangeForRelativeRange.
@Test
public void returnsInitialRangeForRelativeRange() throws Exception {
final RelativeRange range = RelativeRange.create(300);
final DerivedTimeRange derivedTimeRange = DerivedTimeRange.of(range);
assertThat(derivedTimeRange.effectiveTimeRange(emptyRootQuery, null)).isEqualTo(range);
}
Aggregations