Search in sources :

Example 11 with SimpleMessageChunk

use of org.graylog.plugins.views.search.export.SimpleMessageChunk in project graylog2-server by Graylog2.

the class ElasticsearchExportBackendITBase method runWithExpectedResult.

protected void runWithExpectedResult(ExportMessagesCommand command, @SuppressWarnings("SameParameterValue") String resultFields, String... messageValues) {
    SimpleMessageChunk totalResult = collectTotalResult(command);
    assertResultMatches(resultFields, totalResult, messageValues, true);
}
Also used : SimpleMessageChunk(org.graylog.plugins.views.search.export.SimpleMessageChunk)

Example 12 with SimpleMessageChunk

use of org.graylog.plugins.views.search.export.SimpleMessageChunk in project graylog2-server by Graylog2.

the class ElasticsearchExportBackendITBase method marksFirstChunk.

@Test
public void marksFirstChunk() {
    importFixture("messages.json");
    ExportMessagesCommand command = commandBuilderWithAllStreams().build();
    SimpleMessageChunk[] chunks = collectChunksFor(command).toArray(new SimpleMessageChunk[0]);
    assertThat(chunks[0].isFirstChunk()).isTrue();
}
Also used : SimpleMessageChunk(org.graylog.plugins.views.search.export.SimpleMessageChunk) ExportMessagesCommand(org.graylog.plugins.views.search.export.ExportMessagesCommand) Test(org.junit.Test) ElasticsearchBaseTest(org.graylog.testing.elasticsearch.ElasticsearchBaseTest)

Example 13 with SimpleMessageChunk

use of org.graylog.plugins.views.search.export.SimpleMessageChunk in project graylog2-server by Graylog2.

the class ElasticsearchExportBackendITBase method respectsResultLimitIfSet.

@Test
public void respectsResultLimitIfSet() {
    importFixture("messages.json");
    ExportMessagesCommand command = commandBuilderWithAllStreams().chunkSize(1).limit(3).build();
    SimpleMessageChunk totalResult = collectTotalResult(command);
    assertThat(totalResult.messages()).hasSize(3);
}
Also used : SimpleMessageChunk(org.graylog.plugins.views.search.export.SimpleMessageChunk) ExportMessagesCommand(org.graylog.plugins.views.search.export.ExportMessagesCommand) Test(org.junit.Test) ElasticsearchBaseTest(org.graylog.testing.elasticsearch.ElasticsearchBaseTest)

Example 14 with SimpleMessageChunk

use of org.graylog.plugins.views.search.export.SimpleMessageChunk in project graylog2-server by Graylog2.

the class ElasticsearchExportBackendITBase method runWithExpectedResultIgnoringSort.

protected void runWithExpectedResultIgnoringSort(ExportMessagesCommand command, String resultFields, String... messageValues) {
    SimpleMessageChunk totalResult = collectTotalResult(command);
    assertResultMatches(resultFields, totalResult, messageValues, false);
}
Also used : SimpleMessageChunk(org.graylog.plugins.views.search.export.SimpleMessageChunk)

Example 15 with SimpleMessageChunk

use of org.graylog.plugins.views.search.export.SimpleMessageChunk in project graylog2-server by Graylog2.

the class ElasticsearchExportBackendITBase method usesTimeRangeTestLtEqualToTimestampofLastEntry.

// This method tests, that with LT (the upper interval excluded) instead of LTE the message with a TS same as the upper interval is excluded
@Test
public void usesTimeRangeTestLtEqualToTimestampofLastEntry() {
    importFixture("messages.json");
    ExportMessagesCommand command = commandBuilderWithAllStreams().timeRange(timerange("2015-01-01T00:00:00.000Z", "2015-01-01T01:59:59.999Z")).build();
    SimpleMessageChunk totalResult = collectTotalResult(command);
    assertThat(totalResult.messages().stream().map(msg -> msg.fields().get("timestamp")).anyMatch("2015-01-01T01:00:00.000Z"::equals)).isTrue();
    assertThat(totalResult.messages().stream().map(msg -> msg.fields().get("timestamp")).anyMatch("2015-01-01T01:59:59.999Z"::equals)).isFalse();
}
Also used : SimpleMessageChunk(org.graylog.plugins.views.search.export.SimpleMessageChunk) Arrays(java.util.Arrays) ImmutableSet(com.google.common.collect.ImmutableSet) InvalidRangeParametersException(org.graylog2.plugin.indexer.searches.timeranges.InvalidRangeParametersException) SimpleMessage(org.graylog.plugins.views.search.export.SimpleMessage) TestData(org.graylog.plugins.views.search.export.TestData) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ExportException(org.graylog.plugins.views.search.export.ExportException) ExportMessagesCommand(org.graylog.plugins.views.search.export.ExportMessagesCommand) SimpleMessageChunk(org.graylog.plugins.views.search.export.SimpleMessageChunk) Set(java.util.Set) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) ElasticsearchException(org.graylog2.indexer.ElasticsearchException) Sets(com.google.common.collect.Sets) ElasticsearchQueryString(org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) AbsoluteRange(org.graylog2.plugin.indexer.searches.timeranges.AbsoluteRange) ElasticsearchBaseTest(org.graylog.testing.elasticsearch.ElasticsearchBaseTest) IndexLookup(org.graylog.plugins.views.search.elasticsearch.IndexLookup) LinkedHashSet(java.util.LinkedHashSet) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) ExportMessagesCommand(org.graylog.plugins.views.search.export.ExportMessagesCommand) Test(org.junit.Test) ElasticsearchBaseTest(org.graylog.testing.elasticsearch.ElasticsearchBaseTest)

Aggregations

SimpleMessageChunk (org.graylog.plugins.views.search.export.SimpleMessageChunk)17 ExportMessagesCommand (org.graylog.plugins.views.search.export.ExportMessagesCommand)9 ElasticsearchBaseTest (org.graylog.testing.elasticsearch.ElasticsearchBaseTest)9 Test (org.junit.Test)9 LinkedHashSet (java.util.LinkedHashSet)3 ElasticsearchQueryString (org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString)3 SimpleMessage (org.graylog.plugins.views.search.export.SimpleMessage)3 ImmutableSet (com.google.common.collect.ImmutableSet)1 Sets (com.google.common.collect.Sets)1 Arrays (java.util.Arrays)1 Set (java.util.Set)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatExceptionOfType (org.assertj.core.api.Assertions.assertThatExceptionOfType)1 IndexLookup (org.graylog.plugins.views.search.elasticsearch.IndexLookup)1 ExportException (org.graylog.plugins.views.search.export.ExportException)1 TestData (org.graylog.plugins.views.search.export.TestData)1 ElasticsearchException (org.graylog2.indexer.ElasticsearchException)1 AbsoluteRange (org.graylog2.plugin.indexer.searches.timeranges.AbsoluteRange)1 InvalidRangeParametersException (org.graylog2.plugin.indexer.searches.timeranges.InvalidRangeParametersException)1 Before (org.junit.Before)1