Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/sidecar-multi-config-and-tags' i…
Browse files Browse the repository at this point in the history
…nto sidecars-ux-13362
  • Loading branch information
gally47 committed Sep 26, 2022
2 parents c951c83 + 9510911 commit 78f28f0
Show file tree
Hide file tree
Showing 156 changed files with 2,304 additions and 1,324 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ void testInvalidValueType() {
validatableResponse.assertThat().body("explanations.error_type[0]", equalTo("INVALID_VALUE_TYPE"));
}

@ContainerMatrixTest
void testSuccessfullyValidatesExistsTerms() {
verifyQueryIsValidatedSuccessfully("_exists_:timestamp");
verifyQueryIsValidatedSuccessfully("_exists_:level");
}

@ContainerMatrixTest
void testQuotedDefaultField() {
// if the validation correctly recognizes the quoted text, it should not warn about lowercase or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ void testInvalidSearchType() {
.then()
.statusCode(400)
.assertThat()
.body("message", equalTo("Search types do not correspond to view/search types, missing searches: [967d2217-fd99-48a6-b829-5acdab906807]"));
.body("message", equalTo("Search types do not correspond to view/search types, missing searches [967d2217-fd99-48a6-b829-5acdab906808]; search types: [967d2217-fd99-48a6-b829-5acdab906807]; state types: [967d2217-fd99-48a6-b829-5acdab906808]"));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
package org.graylog2.indexer.counts;

import com.google.common.collect.ImmutableMap;
import org.graylog.testing.ContainerMatrixElasticsearchITBaseTest;
import org.graylog.testing.containermatrix.MongodbServer;
import org.graylog.testing.containermatrix.annotations.ContainerMatrixTest;
import org.graylog.testing.containermatrix.annotations.ContainerMatrixTestsConfiguration;
import org.graylog.testing.elasticsearch.BulkIndexRequest;
import org.graylog.testing.elasticsearch.ContainerMatrixElasticsearchBaseTest;
import org.graylog.testing.elasticsearch.SearchServerInstance;
import org.graylog2.indexer.IndexNotFoundException;
import org.graylog2.indexer.IndexSet;
Expand Down Expand Up @@ -50,7 +50,7 @@
// these tests only test the SearchServer, so there is only one MongoDB-version necessary (needed, to launch the tests)
@ContainerMatrixTestsConfiguration(mongoVersions = MongodbServer.MONGO4)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class CountsIT extends ContainerMatrixElasticsearchITBaseTest {
public class CountsIT extends ContainerMatrixElasticsearchBaseTest {
private static final String INDEX_NAME_1 = "index_set_1_counts_test_0";
private static final String INDEX_NAME_2 = "index_set_2_counts_test_0";
private static final String INDEX_NAME_3 = "index_set_3_counts_test_0";
Expand Down Expand Up @@ -81,7 +81,7 @@ public void setUp() {
client().createIndex(INDEX_NAME_3, 1, 0);
client().waitForGreenStatus(INDEX_NAME_1, INDEX_NAME_2, INDEX_NAME_3);

counts = new Counts(indexSetRegistry, countsAdapter());
counts = new Counts(indexSetRegistry, searchServer().adapters().countsAdapter());

indexSetConfig1 = IndexSetConfig.builder()
.id("id-1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import org.apache.commons.codec.binary.Base64;
import org.graylog.testing.ContainerMatrixElasticsearchITBaseTest;
import org.graylog.testing.completebackend.Lifecycle;
import org.graylog.testing.containermatrix.MongodbServer;
import org.graylog.testing.containermatrix.annotations.ContainerMatrixTest;
import org.graylog.testing.containermatrix.annotations.ContainerMatrixTestsConfiguration;
import org.graylog.testing.elasticsearch.ContainerMatrixElasticsearchBaseTest;
import org.graylog.testing.elasticsearch.SearchServerInstance;
import org.graylog2.audit.NullAuditEventSender;
import org.graylog2.indexer.IgnoreIndexTemplate;
Expand Down Expand Up @@ -79,7 +79,7 @@

// these tests only test the SearchServer, so there is only one MongoDB-version necessary (needed, to launch the tests)
@ContainerMatrixTestsConfiguration(serverLifecycle = Lifecycle.CLASS, mongoVersions = MongodbServer.MONGO4)
public class IndicesIT extends ContainerMatrixElasticsearchITBaseTest {
public class IndicesIT extends ContainerMatrixElasticsearchBaseTest {
private static final String INDEX_NAME = "graylog_0";
private final Set<String> indicesToCleanUp = new HashSet<>();

Expand Down Expand Up @@ -122,15 +122,15 @@ protected Map<String, Object> createTemplateFor(String indexWildcard, Map<String
public void setUp() {
//noinspection UnstableApiUsage
eventBus = new EventBus("indices-test");
final Node node = new Node(createNodeAdapter());
final Node node = new Node(searchServer().adapters().nodeAdapter());
final IndexMappingFactory indexMappingFactory = new IndexMappingFactory(node,
ImmutableMap.of(MessageIndexTemplateProvider.MESSAGE_TEMPLATE_TYPE, new MessageIndexTemplateProvider()));
indices = new Indices(
indexMappingFactory,
mock(NodeId.class),
new NullAuditEventSender(),
eventBus,
indicesAdapter()
searchServer().adapters().indicesAdapter()
);
}

Expand Down Expand Up @@ -386,7 +386,7 @@ public void ensureIndexTemplateDoesntThrowOnIgnoreIndexTemplateAndExistingTempla
mock(NodeId.class),
new NullAuditEventSender(),
eventBus,
indicesAdapter());
searchServer().adapters().indicesAdapter());

assertThatCode(() -> indices.ensureIndexTemplate(indexSet)).doesNotThrowAnyException();

Expand Down Expand Up @@ -418,7 +418,7 @@ public void ensureIndexTemplateThrowsOnIgnoreIndexTemplateAndNonExistingTemplate
mock(NodeId.class),
new NullAuditEventSender(),
eventBus,
indicesAdapter());
searchServer().adapters().indicesAdapter());

assertThatCode(() -> indices.ensureIndexTemplate(indexSet))
.isExactlyInstanceOf(IndexTemplateNotFoundException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ClusterES7IT extends ClusterIT {
public final ElasticsearchInstanceES7 elasticsearch = ElasticsearchInstanceES7.create();

@Override
protected SearchServerInstance elasticsearch() {
protected SearchServerInstance searchServer() {
return this.elasticsearch;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,17 @@
*/
package org.graylog.storage.elasticsearch7;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.graylog.storage.elasticsearch7.cat.CatApi;
import org.graylog.storage.elasticsearch7.cluster.ClusterStateApi;
import org.graylog.storage.elasticsearch7.mapping.FieldMappingApi;
import org.graylog.storage.elasticsearch7.stats.StatsApi;
import org.graylog.storage.elasticsearch7.testing.ElasticsearchInstanceES7;
import org.graylog.testing.elasticsearch.SearchServerInstance;
import org.graylog2.indexer.fieldtypes.IndexFieldTypePollerAdapter;
import org.graylog2.indexer.fieldtypes.IndexFieldTypePollerIT;
import org.graylog2.indexer.indices.IndicesAdapter;
import org.graylog2.shared.bindings.providers.ObjectMapperProvider;
import org.junit.Rule;

public class IndexFieldTypePollerES7IT extends IndexFieldTypePollerIT {
@Rule
public final ElasticsearchInstanceES7 elasticsearch = ElasticsearchInstanceES7.create();

private final ObjectMapper objectMapper = new ObjectMapperProvider().get();

@Override
protected IndicesAdapter createIndicesAdapter() {
final ElasticsearchClient client = elasticsearch.elasticsearchClient();
return new IndicesAdapterES7(
client,
new StatsApi(objectMapper, client),
new CatApi(objectMapper, client),
new ClusterStateApi(objectMapper, client)
);
}

@Override
protected IndexFieldTypePollerAdapter createIndexFieldTypePollerAdapter() {
final ElasticsearchClient client = elasticsearch.elasticsearchClient();
return new IndexFieldTypePollerAdapterES7(new FieldMappingApi(objectMapper, client));
}

@Override
protected SearchServerInstance elasticsearch() {
protected SearchServerInstance searchServer() {
return this.elasticsearch;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,8 @@ public class IndicesGetAllMessageFieldsES7IT extends IndicesGetAllMessageFieldsI
@Rule
public final ElasticsearchInstanceES7 elasticsearch = ElasticsearchInstanceES7.create();

private final ObjectMapper objectMapper = new ObjectMapperProvider().get();

@Override
protected IndicesAdapter indicesAdapter() {
final ElasticsearchClient client = elasticsearch.elasticsearchClient();
return new IndicesAdapterES7(
client,
new StatsApi(objectMapper, client),
new CatApi(objectMapper, client),
new ClusterStateApi(objectMapper, client)
);
}

@Override
protected SearchServerInstance elasticsearch() {
protected SearchServerInstance searchServer() {
return elasticsearch;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,17 @@
*/
package org.graylog.storage.elasticsearch7;

import com.codahale.metrics.MetricRegistry;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
import org.graylog.shaded.elasticsearch7.org.elasticsearch.client.core.CountRequest;
import org.graylog.shaded.elasticsearch7.org.elasticsearch.client.core.CountResponse;
import org.graylog.storage.elasticsearch7.testing.ElasticsearchInstanceES7;
import org.graylog.testing.elasticsearch.SearchServerInstance;
import org.graylog2.indexer.messages.ChunkedBulkIndexer;
import org.graylog2.indexer.messages.MessagesAdapter;
import org.graylog2.indexer.messages.MessagesBatchIT;
import org.graylog2.shared.bindings.providers.ObjectMapperProvider;
import org.junit.Rule;

public class MessagesBatchES7IT extends MessagesBatchIT {
@Rule
public final ElasticsearchInstanceES7 elasticsearch = ElasticsearchInstanceES7.create("256m");

private final ObjectMapper objectMapper = new ObjectMapperProvider().get();

@Override
protected SearchServerInstance elasticsearch() {
protected SearchServerInstance searchServer() {
return this.elasticsearch;
}


@Override
protected MessagesAdapter createMessagesAdapter(MetricRegistry metricRegistry) {
return new MessagesAdapterES7(this.elasticsearch.elasticsearchClient(), metricRegistry, new ChunkedBulkIndexer(), objectMapper);
}

@Override
protected long messageCount(String indexName) {
this.elasticsearch.elasticsearchClient().execute((c, requestOptions) -> c.indices().refresh(new RefreshRequest(), requestOptions));

final CountRequest countRequest = new CountRequest(indexName);
final CountResponse result = this.elasticsearch.elasticsearchClient().execute((c, requestOptions) -> c.count(countRequest, requestOptions));

return result.getCount();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,12 @@
*/
package org.graylog.storage.elasticsearch7;

import com.codahale.metrics.MetricRegistry;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
import org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexRequest;
import org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexResponse;
import org.graylog.shaded.elasticsearch7.org.elasticsearch.client.core.CountRequest;
import org.graylog.shaded.elasticsearch7.org.elasticsearch.client.core.CountResponse;
import org.graylog.shaded.elasticsearch7.org.elasticsearch.rest.RestStatus;
import org.graylog.storage.elasticsearch7.testing.ElasticsearchInstanceES7;
import org.graylog.testing.elasticsearch.SearchServerInstance;
import org.graylog2.indexer.messages.ChunkedBulkIndexer;
import org.graylog2.indexer.messages.MessagesAdapter;
import org.graylog2.indexer.messages.MessagesIT;
import org.graylog2.shared.bindings.providers.ObjectMapperProvider;
import org.junit.Rule;

import java.util.Map;
Expand All @@ -38,28 +30,11 @@ public class MessagesES7IT extends MessagesIT {
@Rule
public final ElasticsearchInstanceES7 elasticsearch = ElasticsearchInstanceES7.create();

private final ObjectMapper objectMapper = new ObjectMapperProvider().get();

@Override
protected SearchServerInstance elasticsearch() {
protected SearchServerInstance searchServer() {
return this.elasticsearch;
}

@Override
protected MessagesAdapter createMessagesAdapter(MetricRegistry metricRegistry) {
return new MessagesAdapterES7(this.elasticsearch.elasticsearchClient(), metricRegistry, new ChunkedBulkIndexer(), objectMapper);
}

@Override
protected long messageCount(String indexName) {
this.elasticsearch.elasticsearchClient().execute((c, requestOptions) -> c.indices().refresh(new RefreshRequest(), requestOptions));

final CountRequest countRequest = new CountRequest(indexName);
final CountResponse result = this.elasticsearch.elasticsearchClient().execute((c, requestOptions) -> c.count(countRequest, requestOptions));

return result.getCount();
}

@Override
protected boolean indexMessage(String index, Map<String, Object> source, String id) {
final IndexRequest indexRequest = new IndexRequest(index)
Expand Down
Loading

0 comments on commit 78f28f0

Please sign in to comment.