-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for renaming the setting reindex.remote.allowlist
Signed-off-by: Tianli Feng <ftianli@amazon.com>
- Loading branch information
Tianli Feng
committed
Feb 23, 2022
1 parent
c8dfd68
commit 848dcb4
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexRenamingSettingTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* 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.index.reindex; | ||
|
||
import org.junit.Before; | ||
import org.opensearch.common.settings.Setting; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.test.OpenSearchTestCase; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* 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. | ||
* The test can be removed along with removing support of the deprecated setting. | ||
*/ | ||
public class ReindexRenamingSettingTests extends OpenSearchTestCase { | ||
ReindexPlugin plugin; | ||
|
||
@Before | ||
public void setup() { | ||
this.plugin = new ReindexPlugin(); | ||
} | ||
|
||
public void testReindexSettingsExist() { | ||
List<Setting<?>> settings = plugin.getSettings(); | ||
assertTrue("Both 'reindex.remote.allowlist' and its predecessor should exist in settings of Reindex plugin", | ||
settings.containsAll( | ||
Arrays.asList( | ||
TransportReindexAction.REMOTE_CLUSTER_WHITELIST, | ||
TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST | ||
) | ||
) | ||
); | ||
} | ||
|
||
public void testSettingFallback() { | ||
assertEquals( | ||
TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(Settings.EMPTY), | ||
TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(Settings.EMPTY) | ||
); | ||
} | ||
|
||
public void testSettingGetValue() { | ||
Settings settings = Settings.builder().put("reindex.remote.allowlist", "127.0.0.1:*").build(); | ||
System.out.println(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings)); | ||
assertEquals(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), Arrays.asList("127.0.0.1:*")); | ||
assertEquals(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(settings), Arrays.asList()); | ||
} | ||
|
||
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:*")); | ||
assertSettingDeprecationsAndWarnings(new Setting<?>[]{TransportReindexAction.REMOTE_CLUSTER_WHITELIST}); | ||
} | ||
} |