Search in sources :

Example 6 with SimpleMessageChunk

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

the class ElasticsearchExportBackendIT method assertResultMatches.

private void assertResultMatches(String resultFields, SimpleMessageChunk totalResult, String[] messageValues, boolean expectSorted) {
    Object[][] values = Arrays.stream(messageValues).map(this::toObjectArray).toArray(Object[][]::new);
    SimpleMessageChunk expected = TestData.simpleMessageChunkWithIndexNames(resultFields, values);
    assertThat(totalResult).isEqualTo(expected);
    if (expectSorted) {
        assertThat(totalResult.messages()).containsExactlyElementsOf(expected.messages());
    }
}
Also used : SimpleMessageChunk(org.graylog.plugins.views.search.export.SimpleMessageChunk)

Example 7 with SimpleMessageChunk

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

the class ElasticsearchExportBackendITBase method resultsHaveAllMessageFields.

@Test
public void resultsHaveAllMessageFields() {
    importFixture("messages.json");
    ExportMessagesCommand command = commandBuilderWithAllStreams().fieldsInOrder("timestamp", "message").build();
    LinkedHashSet<SimpleMessageChunk> allChunks = collectChunksFor(command);
    SimpleMessageChunk totalResult = allChunks.iterator().next();
    Set<String> allFieldsInResult = actualFieldNamesFrom(totalResult);
    assertThat(allFieldsInResult).containsExactlyInAnyOrder("gl2_message_id", "source", "message", "timestamp", "streams", "_id");
}
Also used : SimpleMessageChunk(org.graylog.plugins.views.search.export.SimpleMessageChunk) ExportMessagesCommand(org.graylog.plugins.views.search.export.ExportMessagesCommand) ElasticsearchQueryString(org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString) Test(org.junit.Test) ElasticsearchBaseTest(org.graylog.testing.elasticsearch.ElasticsearchBaseTest)

Example 8 with SimpleMessageChunk

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

the class ElasticsearchExportBackendITBase method assertResultMatches.

private void assertResultMatches(String resultFields, SimpleMessageChunk totalResult, String[] messageValues, boolean expectSorted) {
    Object[][] values = Arrays.stream(messageValues).map(this::toObjectArray).toArray(Object[][]::new);
    SimpleMessageChunk expected = TestData.simpleMessageChunkWithIndexNames(resultFields, values);
    assertThat(totalResult).isEqualTo(expected);
    if (expectSorted) {
        assertThat(totalResult.messages()).containsExactlyElementsOf(expected.messages());
    }
}
Also used : SimpleMessageChunk(org.graylog.plugins.views.search.export.SimpleMessageChunk)

Example 9 with SimpleMessageChunk

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

the class ElasticsearchExportBackendITBase method collectTotalResult.

private SimpleMessageChunk collectTotalResult(ExportMessagesCommand command) {
    LinkedHashSet<SimpleMessageChunk> allChunks = collectChunksFor(command);
    LinkedHashSet<SimpleMessage> allMessages = new LinkedHashSet<>();
    for (SimpleMessageChunk chunk : allChunks) {
        keepOnlyRelevantFields(chunk, command.fieldsInOrder());
        allMessages.addAll(chunk.messages());
    }
    return SimpleMessageChunk.from(command.fieldsInOrder(), allMessages);
}
Also used : SimpleMessageChunk(org.graylog.plugins.views.search.export.SimpleMessageChunk) LinkedHashSet(java.util.LinkedHashSet) SimpleMessage(org.graylog.plugins.views.search.export.SimpleMessage)

Example 10 with SimpleMessageChunk

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

the class ElasticsearchExportBackendITBase method deliversCompleteLastChunkIfLimitIsReached.

@Test
public void deliversCompleteLastChunkIfLimitIsReached() {
    importFixture("messages.json");
    ExportMessagesCommand command = commandBuilderWithAllStreams().chunkSize(2).limit(3).build();
    SimpleMessageChunk totalResult = collectTotalResult(command);
    assertThat(totalResult.messages()).hasSize(4);
}
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)

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