Search in sources :

Example 16 with ContainerMatrixTest

use of org.graylog.testing.containermatrix.annotations.ContainerMatrixTest in project graylog2-server by Graylog2.

the class IndicesIT method indexCreationDateReturnsIndexCreationDateOfExistingIndexAsDateTime.

@ContainerMatrixTest
public void indexCreationDateReturnsIndexCreationDateOfExistingIndexAsDateTime() {
    final DateTime now = DateTime.now(DateTimeZone.UTC);
    final String indexName = createRandomIndex("indices_it_");
    final Optional<DateTime> indexCreationDate = indices.indexCreationDate(indexName);
    assertThat(indexCreationDate).isNotEmpty().hasValueSatisfying(date -> assertThat(date.toDate()).isCloseTo(now.toDate(), TimeUnit.SECONDS.toMillis(1)));
}
Also used : ZonedDateTime(java.time.ZonedDateTime) DateTime(org.joda.time.DateTime) ContainerMatrixTest(org.graylog.testing.containermatrix.annotations.ContainerMatrixTest)

Example 17 with ContainerMatrixTest

use of org.graylog.testing.containermatrix.annotations.ContainerMatrixTest in project graylog2-server by Graylog2.

the class SearchMetadataIT method testRetrievingMetadataForStoredSearchWithoutParameter.

@ContainerMatrixTest
void testRetrievingMetadataForStoredSearchWithoutParameter() {
    final ValidatableResponse response = given().spec(requestSpec).when().get("/views/search/metadata/61977428c1f17d26b45c8a0b").then().statusCode(200);
    response.assertThat().body("query_metadata.f1446410-a082-4871-b3bf-d69aa42d0c96.used_parameters_names", empty());
    response.assertThat().body("declared_parameters", anEmptyMap());
}
Also used : ValidatableResponse(io.restassured.response.ValidatableResponse) ContainerMatrixTest(org.graylog.testing.containermatrix.annotations.ContainerMatrixTest)

Example 18 with ContainerMatrixTest

use of org.graylog.testing.containermatrix.annotations.ContainerMatrixTest in project graylog2-server by Graylog2.

the class SuggestionResourceIT method testTypoCorrection.

@ContainerMatrixTest
void testTypoCorrection() {
    final ValidatableResponse validatableResponse = given().spec(requestSpec).when().body("{\"field\":\"facility\", \"input\":\"tets\"}").post("/search/suggest").then().statusCode(200);
    validatableResponse.assertThat().body("suggestions.value[0]", equalTo("test"));
    validatableResponse.assertThat().body("suggestions.occurrence[0]", greaterThanOrEqualTo(1));
}
Also used : ValidatableResponse(io.restassured.response.ValidatableResponse) ContainerMatrixTest(org.graylog.testing.containermatrix.annotations.ContainerMatrixTest)

Example 19 with ContainerMatrixTest

use of org.graylog.testing.containermatrix.annotations.ContainerMatrixTest in project graylog2-server by Graylog2.

the class SuggestionResourceIT method testInvalidField.

@ContainerMatrixTest
void testInvalidField() {
    final ValidatableResponse validatableResponse = given().spec(requestSpec).when().body("{\"field\":\"message\", \"input\":\"foo\"}").post("/search/suggest").then().statusCode(200);
    // error types and messages are different for each ES version, so let's just check that there is an error in the response
    validatableResponse.assertThat().body("error", notNullValue());
}
Also used : ValidatableResponse(io.restassured.response.ValidatableResponse) ContainerMatrixTest(org.graylog.testing.containermatrix.annotations.ContainerMatrixTest)

Example 20 with ContainerMatrixTest

use of org.graylog.testing.containermatrix.annotations.ContainerMatrixTest in project graylog2-server by Graylog2.

the class CountsIT method totalReturnsZeroWithNoIndices.

@ContainerMatrixTest
@Order(2)
public void totalReturnsZeroWithNoIndices() {
    final BulkIndexRequest bulkIndexRequest = new BulkIndexRequest();
    for (int i = 0; i < 10; i++) {
        final Map<String, Object> source = ImmutableMap.of("foo", "bar", "counter", i);
        bulkIndexRequest.addRequest(INDEX_NAME_3, source);
    }
    client().bulkIndex(bulkIndexRequest);
    // Simulate no indices for the second index set.
    when(indexSet2.getManagedIndices()).thenReturn(new String[0]);
    assertThat(counts.total(indexSet1)).isEqualTo(0L);
    assertThat(counts.total(indexSet2)).isEqualTo(0L);
    assertThat(counts.total(indexSet3)).isEqualTo(10L);
    // Simulate no indices for all index sets.
    when(indexSetRegistry.getManagedIndices()).thenReturn(new String[0]);
    assertThat(counts.total()).isEqualTo(0L);
}
Also used : BulkIndexRequest(org.graylog.testing.elasticsearch.BulkIndexRequest) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) ContainerMatrixTest(org.graylog.testing.containermatrix.annotations.ContainerMatrixTest)

Aggregations

ContainerMatrixTest (org.graylog.testing.containermatrix.annotations.ContainerMatrixTest)23 ValidatableResponse (io.restassured.response.ValidatableResponse)14 IndexSet (org.graylog2.indexer.IndexSet)4 ZonedDateTime (java.time.ZonedDateTime)3 DateTime (org.joda.time.DateTime)3 BulkIndexRequest (org.graylog.testing.elasticsearch.BulkIndexRequest)2 TestIndexSet (org.graylog2.indexer.TestIndexSet)2 IndexRangeStats (org.graylog2.indexer.searches.IndexRangeStats)2 Response (io.restassured.response.Response)1 IndexNotFoundException (org.graylog2.indexer.IndexNotFoundException)1 IndexSetStatsCreator (org.graylog2.indexer.IndexSetStatsCreator)1 IndexSetStats (org.graylog2.rest.resources.system.indexer.responses.IndexSetStats)1 Order (org.junit.jupiter.api.Order)1 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)1