Skip to content

Commit

Permalink
Fixing up IT.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisoelkers committed Jul 17, 2023
1 parent b8f4ec2 commit 60b1b7d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class IndicesIT extends ContainerMatrixElasticsearchBaseTest {
.id("index-set-1")
.title("Index set 1")
.description("For testing")
.indexPrefix("graylog")
.indexPrefix("test_index_set")
.creationDate(ZonedDateTime.now())
.shards(1)
.replicas(0)
Expand All @@ -103,7 +103,6 @@ public class IndicesIT extends ContainerMatrixElasticsearchBaseTest {
protected static final IndexSet indexSet = new TestIndexSet(indexSetConfig);
private final Set<String> indicesToCleanUp = new HashSet<>();
protected Indices indices;
@SuppressWarnings("UnstableApiUsage")
private EventBus eventBus;
private final NodeId nodeId = new SimpleNodeId("5ca1ab1e-0000-4000-a000-000000000000");

Expand All @@ -121,7 +120,6 @@ protected Map<String, Object> createTemplateFor(String indexWildcard, Map<String

@BeforeEach
public void setUp() {
//noinspection UnstableApiUsage
eventBus = new EventBus("indices-test");
final Node node = new Node(searchServer().adapters().nodeAdapter());
final IndexMappingFactory indexMappingFactory = new IndexMappingFactory(node,
Expand Down Expand Up @@ -274,9 +272,7 @@ public void indexRangeStatsThrowsExceptionIfIndexIsClosed() {

@ContainerMatrixTest
public void indexRangeStatsThrowsExceptionIfIndexDoesNotExists() {
assertThrows(IndexNotFoundException.class, () -> {
indices.indexRangeStatsOfIndex("does-not-exist");
});
assertThrows(IndexNotFoundException.class, () -> indices.indexRangeStatsOfIndex("does-not-exist"));
}

@ContainerMatrixTest
Expand Down Expand Up @@ -306,7 +302,7 @@ public void createOverwritesIndexTemplate() {
"properties", ImmutableMap.of("message",
ImmutableMap.of("type", "text")));

var templateSource = Template.create(indexSet.getIndexWildcard(), new Template.Mappings(beforeMapping), 0L, new Template.Settings(Map.of()));
var templateSource = Template.create(indexSet.getIndexWildcard(), new Template.Mappings(beforeMapping), 1L, new Template.Settings(Map.of()));

client().putTemplate(templateName, templateSource);

Expand Down Expand Up @@ -409,7 +405,7 @@ public void ensureIndexTemplateThrowsOnIgnoreIndexTemplateAndNonExistingTemplate

try {
indices.deleteIndexTemplate(indexSet);
} catch (Exception e) {
} catch (Exception ignored) {
}

assertThat(client().templateExists(templateName)).isFalse();
Expand Down Expand Up @@ -651,7 +647,6 @@ public void cyclingAliasLeavesOldIndexInPlace() {
assertThat(indices.exists(index1)).isTrue();
}

@SuppressWarnings("UnstableApiUsage")
public static final class IndicesEventListener {
final List<IndicesClosedEvent> indicesClosedEvents = Collections.synchronizedList(new ArrayList<>());
final List<IndicesDeletedEvent> indicesDeletedEvents = Collections.synchronizedList(new ArrayList<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
import org.graylog.shaded.opensearch2.org.opensearch.client.indices.DeleteComposableIndexTemplateRequest;
import org.graylog.shaded.opensearch2.org.opensearch.client.indices.GetComposableIndexTemplateRequest;
import org.graylog.shaded.opensearch2.org.opensearch.client.indices.GetIndexRequest;
import org.graylog.shaded.opensearch2.org.opensearch.client.indices.GetIndexTemplatesRequest;
import org.graylog.shaded.opensearch2.org.opensearch.client.indices.GetIndexTemplatesResponse;
import org.graylog.shaded.opensearch2.org.opensearch.client.indices.GetMappingsRequest;
import org.graylog.shaded.opensearch2.org.opensearch.client.indices.GetMappingsResponse;
import org.graylog.shaded.opensearch2.org.opensearch.client.indices.PutComposableIndexTemplateRequest;
Expand Down Expand Up @@ -164,11 +162,12 @@ private Stream<Map.Entry<String, JsonNode>> extractFieldMappings(String index, J

@Override
public boolean templateExists(String templateName) {
final GetIndexTemplatesRequest request = new GetIndexTemplatesRequest("*");
final GetIndexTemplatesResponse result = client.execute((c, requestOptions) -> c.indices().getIndexTemplate(request, requestOptions));
var request = new GetComposableIndexTemplateRequest("");
var result = client.execute((c, requestOptions) -> c.indices().getIndexTemplate(request, requestOptions));
return result.getIndexTemplates()
.keySet()
.stream()
.anyMatch(indexTemplate -> indexTemplate.name().equals(templateName));
.anyMatch(indexTemplate -> indexTemplate.equals(templateName));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void addGraylogDefaultIndexTemplate() {
private static Map<String, Template> getGraylogDefaultMessageTemplates(SearchVersion version) {
var template =
new MessageIndexTemplateProvider().create(version, null)
.messageTemplate("*", "standard", 1L);
.messageTemplate("*", "standard", 100L);
return Collections.singletonMap("graylog-test-internal", template);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void addGraylogDefaultIndexTemplate() {

private static Map<String, Template> getGraylogDefaultMessageTemplates(SearchVersion version) {
var template = new MessageIndexTemplateProvider().create(version, null)
.messageTemplate("*", "standard", 0L);
.messageTemplate("*", "standard", 100L);
return Collections.singletonMap("graylog-test-internal", template);
}

Expand Down

0 comments on commit 60b1b7d

Please sign in to comment.