Search in sources :

Example 21 with InvalidRangeParametersException

use of org.graylog2.plugin.indexer.searches.timeranges.InvalidRangeParametersException in project graylog2-server by Graylog2.

the class ESTimeHandlerTest method timeSpecIntervalIsCalculatedOnQueryTimeRangeIfNoPivotTimeRange.

@Test
public void timeSpecIntervalIsCalculatedOnQueryTimeRangeIfNoPivotTimeRange() throws InvalidRangeParametersException {
    final ArgumentCaptor<TimeRange> timeRangeCaptor = ArgumentCaptor.forClass(TimeRange.class);
    when(interval.toDateInterval(timeRangeCaptor.capture())).thenReturn(DateInterval.days(1));
    when(pivot.timerange()).thenReturn(Optional.empty());
    when(query.timerange()).thenReturn(RelativeRange.create(2323));
    this.esTimeHandler.doCreateAggregation("foobar", pivot, time, esPivot, queryContext, query);
    final TimeRange argumentTimeRange = timeRangeCaptor.getValue();
    assertThat(argumentTimeRange).isEqualTo(RelativeRange.create(2323));
}
Also used : TimeRange(org.graylog2.plugin.indexer.searches.timeranges.TimeRange) DerivedTimeRange(org.graylog.plugins.views.search.timeranges.DerivedTimeRange) Test(org.junit.Test)

Example 22 with InvalidRangeParametersException

use of org.graylog2.plugin.indexer.searches.timeranges.InvalidRangeParametersException in project graylog2-server by Graylog2.

the class ElasticsearchBackendSearchTypeOverridesTest method timerangeOverridesAffectIndicesSelection.

@Test
public void timerangeOverridesAffectIndicesSelection() throws IOException, InvalidRangeParametersException {
    when(indexLookup.indexNamesForStreamsInTimeRange(ImmutableSet.of("stream1"), timeRangeForTest())).thenReturn(ImmutableSet.of("queryIndex"));
    TimeRange tr = AbsoluteRange.create("2019-09-11T10:31:52.819Z", "2019-09-11T10:36:52.823Z");
    when(indexLookup.indexNamesForStreamsInTimeRange(ImmutableSet.of("stream1"), tr)).thenReturn(ImmutableSet.of("searchTypeIndex"));
    final ESGeneratedQueryContext queryContext = this.elasticsearchBackend.generate(searchJob, query, new SearchConfig(Period.ZERO));
    final MultiSearchResponse response = TestMultisearchResponse.fromFixture("successfulMultiSearchResponse.json");
    final List<MultiSearchResponse.Item> items = Arrays.stream(response.getResponses()).collect(Collectors.toList());
    when(client.msearch(any(), any())).thenReturn(items);
    final List<SearchRequest> generatedRequest = run(searchJob, query, queryContext, Collections.emptySet());
    assertThat(indicesOf(generatedRequest)).hasSize(2).containsExactly("searchTypeIndex", "queryIndex");
}
Also used : TimeRange(org.graylog2.plugin.indexer.searches.timeranges.TimeRange) DerivedTimeRange(org.graylog.plugins.views.search.timeranges.DerivedTimeRange) MultiSearchResponse(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.MultiSearchResponse) SearchRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest) SearchConfig(org.graylog.plugins.views.search.engine.SearchConfig) Test(org.junit.Test)

Aggregations

TimeRange (org.graylog2.plugin.indexer.searches.timeranges.TimeRange)13 DerivedTimeRange (org.graylog.plugins.views.search.timeranges.DerivedTimeRange)10 Test (org.junit.Test)9 InvalidRangeParametersException (org.graylog2.plugin.indexer.searches.timeranges.InvalidRangeParametersException)8 BasicDBObject (com.mongodb.BasicDBObject)3 DashboardWidget (org.graylog2.dashboards.widgets.DashboardWidget)3 InvalidWidgetConfigurationException (org.graylog2.dashboards.widgets.InvalidWidgetConfigurationException)3 ResultMessage (org.graylog2.indexer.results.ResultMessage)3 Message (org.graylog2.plugin.Message)3 MessageSummary (org.graylog2.plugin.MessageSummary)3 Timed (com.codahale.metrics.annotation.Timed)2 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 BadRequestException (javax.ws.rs.BadRequestException)2 Produces (javax.ws.rs.Produces)2 ElasticsearchQueryString (org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString)2 SearchConfig (org.graylog.plugins.views.search.engine.SearchConfig)2