Skip to content

Commit

Permalink
Merge branch 'main' into replace-master-int-server-main
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianli Feng committed Mar 19, 2022
2 parents 89ad4b9 + a853253 commit eec54ae
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import java.util.Arrays;
import java.util.List;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItems;

/**
* A unit test to validate the former name of the setting 'reindex.remote.allowlist' still take effect,
* after it is deprecated, so that the backwards compatibility is maintained.
Expand All @@ -28,21 +31,20 @@ public class ReindexRenamedSettingTests extends OpenSearchTestCase {
*/
public void testReindexSettingsExist() {
List<Setting<?>> settings = plugin.getSettings();
assertTrue(
assertThat(
"Both 'reindex.remote.allowlist' and its predecessor should be supported settings of Reindex plugin",
settings.containsAll(
Arrays.asList(TransportReindexAction.REMOTE_CLUSTER_WHITELIST, TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST)
)
settings,
hasItems(TransportReindexAction.REMOTE_CLUSTER_WHITELIST, TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST)
);
}

/**
* Validate the default value of the both settings is the same.
*/
public void testSettingFallback() {
assertEquals(
assertThat(
TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(Settings.EMPTY),
TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(Settings.EMPTY)
equalTo(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(Settings.EMPTY))
);
}

Expand All @@ -51,10 +53,10 @@ public void testSettingFallback() {
*/
public void testSettingGetValue() {
Settings settings = Settings.builder().put("reindex.remote.allowlist", "127.0.0.1:*").build();
assertEquals(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), Arrays.asList("127.0.0.1:*"));
assertEquals(
assertThat(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), equalTo(Arrays.asList("127.0.0.1:*")));
assertThat(
TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(settings),
TransportReindexAction.REMOTE_CLUSTER_WHITELIST.getDefault(Settings.EMPTY)
equalTo(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.getDefault(Settings.EMPTY))
);
}

Expand All @@ -63,7 +65,7 @@ public void testSettingGetValue() {
*/
public void testSettingGetValueWithFallback() {
Settings settings = Settings.builder().put("reindex.remote.whitelist", "127.0.0.1:*").build();
assertEquals(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), Arrays.asList("127.0.0.1:*"));
assertThat(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), equalTo(Arrays.asList("127.0.0.1:*")));
assertSettingDeprecationsAndWarnings(new Setting<?>[] { TransportReindexAction.REMOTE_CLUSTER_WHITELIST });
}

Expand All @@ -75,8 +77,8 @@ public void testSettingGetValueWhenBothAreConfigured() {
.put("reindex.remote.allowlist", "127.0.0.1:*")
.put("reindex.remote.whitelist", "[::1]:*, 127.0.0.1:*")
.build();
assertEquals(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), Arrays.asList("127.0.0.1:*"));
assertEquals(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(settings), Arrays.asList("[::1]:*", "127.0.0.1:*"));
assertThat(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), equalTo(Arrays.asList("127.0.0.1:*")));
assertThat(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(settings), equalTo(Arrays.asList("[::1]:*", "127.0.0.1:*")));
assertSettingDeprecationsAndWarnings(new Setting<?>[] { TransportReindexAction.REMOTE_CLUSTER_WHITELIST });
}

Expand Down

0 comments on commit eec54ae

Please sign in to comment.