Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Add tests for RemoteGlobalMetadataManager #14458

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void testSerDe() throws IOException {
}
}

private CoordinationMetadata getCoordinationMetadata() {
public static CoordinationMetadata getCoordinationMetadata() {
return CoordinationMetadata.builder()
.term(TERM)
.lastAcceptedConfiguration(new VotingConfiguration(Set.of("node1")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void testSerDe() throws IOException {
}
}

private Custom getCustomMetadata() {
public static Custom getCustomMetadata() {
return IndexGraveyard.builder().addTombstone(new Index("test-index", "3q2423")).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void testSerDe() throws IOException {
}
}

private Metadata getGlobalMetadata() {
public static Metadata getGlobalMetadata() {
return Metadata.builder()
.templates(
TemplatesMetadata.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void testSerDe() throws IOException {
}
}

private DiffableStringMap getHashesOfConsistentSettings() {
public static DiffableStringMap getHashesOfConsistentSettings() {
Map<String, String> hashesOfConsistentSettings = new HashMap<>();
hashesOfConsistentSettings.put("secure-setting-key", "secure-setting-value");
return new DiffableStringMap(hashesOfConsistentSettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public void testSerDe() throws IOException {
}
}

private Settings getSettings() {
public static Settings getSettings() {
return Settings.builder().put("random_index_setting_" + randomAlphaOfLength(3), randomAlphaOfLength(5)).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void testSerDe() throws IOException {
}
}

private TemplatesMetadata getTemplatesMetadata() {
public static TemplatesMetadata getTemplatesMetadata() {
return TemplatesMetadata.builder()
.put(
IndexTemplateMetadata.builder("template" + randomAlphaOfLength(3))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.common.util;

import org.opensearch.core.action.ActionListener;

/**
* A simple implementation of {@link ActionListener} that captures the response and failures used for testing purposes.
*
* @param <T> the result type
*/
public class TestCapturingListener<T> implements ActionListener<T> {
private T result;
private Exception failure;

@Override
public void onResponse(T result) {
this.result = result;
}

@Override
public void onFailure(Exception e) {
this.failure = e;
}

public T getResult() {
return result;
}

public Exception getFailure() {
return failure;
}
}
Loading