use of org.graylog.testing.containermatrix.annotations.ContainerMatrixTest in project graylog2-server by Graylog2.
the class MessagesResourceIT method testInvalidQueryResponse.
@ContainerMatrixTest
void testInvalidQueryResponse() {
sut.importElasticsearchFixture("messages-for-export.json", MessagesResourceIT.class);
String allMessagesTimeRange = "{\"timerange\": {\"type\": \"absolute\", \"from\": \"2015-01-01T00:00:00\", \"to\": \"2015-01-01T23:59:59\"}}";
Response r = given().spec(requestSpec).accept("text/csv").body(allMessagesTimeRange).expect().response().statusCode(200).contentType("text/csv").when().post("/views/search/messages");
String[] resultLines = r.asString().split("\n");
assertThat(resultLines).startsWith("\"timestamp\",\"source\",\"message\"").as("should contain header");
assertThat(Arrays.copyOfRange(resultLines, 1, 5)).containsExactlyInAnyOrder("\"2015-01-01T04:00:00.000Z\",\"source-2\",\"Ho\"", "\"2015-01-01T03:00:00.000Z\",\"source-1\",\"Hi\"", "\"2015-01-01T02:00:00.000Z\",\"source-2\",\"He\"", "\"2015-01-01T01:00:00.000Z\",\"source-1\",\"Ha\"");
}
use of org.graylog.testing.containermatrix.annotations.ContainerMatrixTest in project graylog2-server by Graylog2.
the class CountsIT method totalSucceedsWithListOfIndicesLargerThan4Kilobytes.
@ContainerMatrixTest
public void totalSucceedsWithListOfIndicesLargerThan4Kilobytes() {
final int numberOfIndices = 100;
final String[] indexNames = new String[numberOfIndices];
final String indexPrefix = "very_long_list_of_indices_0123456789_counts_it_";
final IndexSet indexSet = mock(IndexSet.class);
for (int i = 0; i < numberOfIndices; i++) {
final String indexName = indexPrefix + i;
client().createIndex(indexName);
indexNames[i] = indexName;
}
when(indexSet.getManagedIndices()).thenReturn(indexNames);
final String indicesString = String.join(",", indexNames);
assertThat(indicesString.length()).isGreaterThanOrEqualTo(4096);
assertThat(counts.total(indexSet)).isEqualTo(0L);
}
use of org.graylog.testing.containermatrix.annotations.ContainerMatrixTest in project graylog2-server by Graylog2.
the class CountsIT method totalReturnsNumberOfMessages.
@ContainerMatrixTest
public void totalReturnsNumberOfMessages() {
final BulkIndexRequest bulkIndexRequest = new BulkIndexRequest();
final int count1 = 10;
for (int i = 0; i < count1; i++) {
final Map<String, Object> source = ImmutableMap.of("foo", "bar", "counter", i);
bulkIndexRequest.addRequest(INDEX_NAME_1, source);
}
final int count2 = 5;
for (int i = 0; i < count2; i++) {
final Map<String, Object> source = ImmutableMap.of("foo", "bar", "counter", i);
bulkIndexRequest.addRequest(INDEX_NAME_2, source);
}
client().bulkIndex(bulkIndexRequest);
assertThat(counts.total()).isEqualTo(count1 + count2);
assertThat(counts.total(indexSet1)).isEqualTo(count1);
assertThat(counts.total(indexSet2)).isEqualTo(count2);
}
use of org.graylog.testing.containermatrix.annotations.ContainerMatrixTest in project graylog2-server by Graylog2.
the class CountsIT method totalThrowsElasticsearchExceptionIfIndexDoesNotExist.
@ContainerMatrixTest
public void totalThrowsElasticsearchExceptionIfIndexDoesNotExist() {
final IndexSet indexSet = mock(IndexSet.class);
when(indexSet.getManagedIndices()).thenReturn(new String[] { "does_not_exist" });
try {
counts.total(indexSet);
fail("Expected IndexNotFoundException");
} catch (IndexNotFoundException e) {
final String expectedErrorDetail = "Index not found for query: does_not_exist. Try recalculating your index ranges.";
assertThat(e).hasMessageStartingWith("Fetching message count failed for indices [does_not_exist]").hasMessageEndingWith(expectedErrorDetail).hasNoSuppressedExceptions();
assertThat(e.getErrorDetails()).containsExactly(expectedErrorDetail);
}
}
use of org.graylog.testing.containermatrix.annotations.ContainerMatrixTest in project graylog2-server by Graylog2.
the class IndicesIT method getIndices.
@ContainerMatrixTest
public void getIndices() {
final IndexSet indexSet = new TestIndexSet(indexSetConfig.toBuilder().indexPrefix("indices_it").build());
final String index1 = createRandomIndex("indices_it_");
final String index2 = createRandomIndex("indices_it_");
client().closeIndex(index2);
assertThat(indices.getIndices(indexSet)).containsOnly(index1, index2);
assertThat(indices.getIndices(indexSet, "open", "close")).containsOnly(index1, index2);
assertThat(indices.getIndices(indexSet, "open")).containsOnly(index1);
assertThat(indices.getIndices(indexSet, "close")).containsOnly(index2);
}
Aggregations