use of org.graylog2.indexer.TestIndexSet in project graylog2-server by Graylog2.
the class SearchesIT method testCountWithFilter.
@Test
public void testCountWithFilter() throws Exception {
importFixture("org/graylog2/indexer/searches/SearchesIT.json");
final IndexSetConfig indexSetConfig = IndexSetConfig.builder().id("id").title("title").indexPrefix("prefix").shards(1).replicas(0).rotationStrategy(MessageCountRotationStrategyConfig.createDefault()).retentionStrategyClass(DeletionRetentionStrategy.class.getCanonicalName()).retentionStrategy(DeletionRetentionStrategyConfig.createDefault()).creationDate(ZonedDateTime.of(2017, 5, 24, 0, 0, 0, 0, ZoneOffset.UTC)).indexAnalyzer("standard").indexTemplateName("template").indexOptimizationMaxNumSegments(1).indexOptimizationDisabled(false).build();
final IndexSet indexSet = new TestIndexSet(indexSetConfig);
final Stream stream = new FakeStream("test") {
@Override
public IndexSet getIndexSet() {
return indexSet;
}
};
when(streamService.load(STREAM_ID)).thenReturn(stream);
CountResult result = searches.count("*", AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC)), "streams:" + STREAM_ID);
assertThat(result.count()).isEqualTo(5L);
}
use of org.graylog2.indexer.TestIndexSet in project graylog2-server by Graylog2.
the class SearchesIT method determineAffectedIndicesWithRangesExcludeEvents.
@Test
public void determineAffectedIndicesWithRangesExcludeEvents() throws Exception {
final Set<IndexSet> eventIndexSets = Arrays.asList("gl-events", "gl-system-events").stream().map(prefix -> new TestIndexSet(indexSet.getConfig().toBuilder().indexPrefix(prefix).indexTemplateType(EVENT_TEMPLATE_TYPE).build())).collect(Collectors.toSet());
when(indexSetRegistry.getForIndices(anyCollection())).thenReturn(eventIndexSets);
final DateTime now = DateTime.now(DateTimeZone.UTC);
final MongoIndexRange indexRange0 = MongoIndexRange.create("gl-events_0", now, now.plusDays(1), now, 0);
final MongoIndexRange indexRange1 = MongoIndexRange.create("gl-system-events_2", now.plusDays(1), now.plusDays(2), now, 0);
final MongoIndexRange indexRange2 = MongoIndexRange.create("graylog_0", now, now.plusDays(1), now, 0);
final SortedSet<IndexRange> indices = ImmutableSortedSet.orderedBy(IndexRange.COMPARATOR).add(indexRange0).add(indexRange1).add(indexRange2).build();
when(indexRangeService.find(any(DateTime.class), any(DateTime.class))).thenReturn(indices);
final TimeRange absoluteRange = AbsoluteRange.create(now.minusDays(1), now.plusDays(1));
assertThat(searches.determineAffectedIndicesWithRanges(absoluteRange, null)).containsExactly(indexRange2);
}
use of org.graylog2.indexer.TestIndexSet in project graylog2-server by Graylog2.
the class IndexFieldTypePollerIT method setUp.
@Before
public void setUp() throws Exception {
final Node node = mock(Node.class);
@SuppressWarnings("UnstableApiUsage") final Indices indices = new Indices(new IndexMappingFactory(node, ImmutableMap.of(MESSAGE_TEMPLATE_TYPE, new MessageIndexTemplateProvider())), mock(NodeId.class), new NullAuditEventSender(), mock(EventBus.class), createIndicesAdapter());
poller = new IndexFieldTypePoller(indices, new MetricRegistry(), createIndexFieldTypePollerAdapter());
indexSet = new TestIndexSet(indexSetConfig);
importFixture("org/graylog2/indexer/fieldtypes/IndexFieldTypePollerIT.json");
}
use of org.graylog2.indexer.TestIndexSet in project graylog2-server by Graylog2.
the class IndicesIT method getIndices.
@ContainerMatrixTest
public void getIndices() {
final IndexSet indexSet = new TestIndexSet(indexSetConfig.toBuilder().indexPrefix("indices_it").build());
final String index1 = createRandomIndex("indices_it_");
final String index2 = createRandomIndex("indices_it_");
client().closeIndex(index2);
assertThat(indices.getIndices(indexSet)).containsOnly(index1, index2);
assertThat(indices.getIndices(indexSet, "open", "close")).containsOnly(index1, index2);
assertThat(indices.getIndices(indexSet, "open")).containsOnly(index1);
assertThat(indices.getIndices(indexSet, "close")).containsOnly(index2);
}
Aggregations