Search in sources :

Example 6 with ExportMessagesCommand

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

the class ElasticsearchExportBackendScrollingIT method containsAllResultsInNoParticularOrder.

@Test
public void containsAllResultsInNoParticularOrder() {
    importFixture("messages.json");
    ExportMessagesCommand command = commandBuilderWithAllStreams().build();
    runWithExpectedResultIgnoringSort(command, "timestamp,source,message", "graylog_0, 2015-01-01T01:00:00.000Z, source-1, Ha", "graylog_1, 2015-01-01T01:59:59.999Z, source-2, He", "graylog_0, 2015-01-01T03:00:00.000Z, source-1, Hi", "graylog_0, 2015-01-01T04:00:00.000Z, source-2, Ho");
}
Also used : ExportMessagesCommand(org.graylog.plugins.views.search.export.ExportMessagesCommand) Test(org.junit.Test)

Example 7 with ExportMessagesCommand

use of org.graylog.plugins.views.search.export.ExportMessagesCommand 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 ExportMessagesCommand

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

the class ElasticsearchExportBackendITBase method usesTimeRangeTestLt.

// This method tests, that with LT (the upper interval excluded) instead of LTE the message with a TS 1 ms lower than the upper interval is still included
@Test
public void usesTimeRangeTestLt() {
    importFixture("messages.json");
    ExportMessagesCommand command = commandBuilderWithAllStreams().timeRange(timerange("2015-01-01T00:00:00.000Z", "2015-01-01T02:00:00.000Z")).build();
    runWithExpectedResultIgnoringSort(command, "timestamp,source,message", "graylog_1, 2015-01-01T01:59:59.999Z, source-2, He", "graylog_0, 2015-01-01T01:00:00.000Z, source-1, Ha");
}
Also used : ExportMessagesCommand(org.graylog.plugins.views.search.export.ExportMessagesCommand) Test(org.junit.Test) ElasticsearchBaseTest(org.graylog.testing.elasticsearch.ElasticsearchBaseTest)

Example 9 with ExportMessagesCommand

use of org.graylog.plugins.views.search.export.ExportMessagesCommand 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)

Example 10 with ExportMessagesCommand

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

the class ElasticsearchExportBackendITBase method failsWithLeadingHighlightQueryIfDisallowed.

@Test
public void failsWithLeadingHighlightQueryIfDisallowed() {
    importFixture("messages.json");
    ExportMessagesCommand command = commandBuilderWithAllStreams().queryString(ElasticsearchQueryString.of("*a")).build();
    assertThatExceptionOfType(ExportException.class).isThrownBy(() -> sut.run(command, chunk -> {
    })).withCauseInstanceOf(ElasticsearchException.class);
}
Also used : ExportMessagesCommand(org.graylog.plugins.views.search.export.ExportMessagesCommand) Test(org.junit.Test) ElasticsearchBaseTest(org.graylog.testing.elasticsearch.ElasticsearchBaseTest)

Aggregations

ExportMessagesCommand (org.graylog.plugins.views.search.export.ExportMessagesCommand)29 Test (org.junit.Test)23 ElasticsearchBaseTest (org.graylog.testing.elasticsearch.ElasticsearchBaseTest)21 SimpleMessageChunk (org.graylog.plugins.views.search.export.SimpleMessageChunk)9 ApiOperation (io.swagger.annotations.ApiOperation)3 POST (javax.ws.rs.POST)3 ElasticsearchQueryString (org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString)3 NoAuditEvent (org.graylog2.audit.jersey.NoAuditEvent)3 Test (org.junit.jupiter.api.Test)3 Search (io.searchbox.core.Search)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Search (org.graylog.plugins.views.search.Search)2 ResultFormat (org.graylog.plugins.views.search.export.ResultFormat)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Sets (com.google.common.collect.Sets)1 Arrays (java.util.Arrays)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 BadRequestException (javax.ws.rs.BadRequestException)1