This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate setting 'reindex.remote.whitelist' and introduce the altern…
…ative setting 'reindex.remote.allowlist' (opensearch-project#2221) * Add setting reindex.remote.allowlist, and deprecate setting reindex.remote.whitelist Signed-off-by: Tianli Feng <ftianli@amazon.com> * Add unit test for renaming the setting reindex.remote.allowlist Signed-off-by: Tianli Feng <ftianli@amazon.com> * Remove system.out.println() Signed-off-by: Tianli Feng <ftianli@amazon.com> * Adjust format by spotlessApply task Signed-off-by: Tianli Feng <ftianli@amazon.com> * Replace REMOTE_CLUSTER_WHITELIST with REMOTE_CLUSTER_ALLOWLIST Signed-off-by: Tianli Feng <ftianli@amazon.com> * Add a unit test to test final setting value when both settings have got a value Signed-off-by: Tianli Feng <ftianli@amazon.com> * Rename the unit test class name Signed-off-by: Tianli Feng <ftianli@amazon.com> * Remove the Access modifiers public from the constant REMOTE_CLUSTER_WHITELIST Signed-off-by: Tianli Feng <ftianli@amazon.com> * Initialize ReindexPlugin without using the @before method Signed-off-by: Tianli Feng <ftianli@amazon.com> * Rename 'unwhitelisted' to 'unallowlisted' in a yml file used for REST api testing. Signed-off-by: Tianli Feng <ftianli@amazon.com>
- Loading branch information
Tianli Feng
authored
Mar 8, 2022
1 parent
65debde
commit 63c75d1
Showing
10 changed files
with
103 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
83 changes: 83 additions & 0 deletions
83
modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexRenamedSettingTests.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,83 @@ | ||
/* | ||
* 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.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 ReindexRenamedSettingTests extends OpenSearchTestCase { | ||
private final ReindexPlugin plugin = new ReindexPlugin(); | ||
|
||
/** | ||
* Validate the both settings are known and supported. | ||
*/ | ||
public void testReindexSettingsExist() { | ||
List<Setting<?>> settings = plugin.getSettings(); | ||
assertTrue( | ||
"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) | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Validate the default value of the both settings is the same. | ||
*/ | ||
public void testSettingFallback() { | ||
assertEquals( | ||
TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(Settings.EMPTY), | ||
TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(Settings.EMPTY) | ||
); | ||
} | ||
|
||
/** | ||
* Validate the new setting can be configured correctly, and it doesn't impact the old setting. | ||
*/ | ||
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( | ||
TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(settings), | ||
TransportReindexAction.REMOTE_CLUSTER_WHITELIST.getDefault(Settings.EMPTY) | ||
); | ||
} | ||
|
||
/** | ||
* Validate the value of the old setting will be applied to the new setting, if the new setting is not configured. | ||
*/ | ||
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 }); | ||
} | ||
|
||
/** | ||
* Validate the value of the old setting will be ignored, if the new setting is configured. | ||
*/ | ||
public void testSettingGetValueWhenBothAreConfigured() { | ||
Settings settings = Settings.builder() | ||
.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:*")); | ||
assertSettingDeprecationsAndWarnings(new Setting<?>[] { TransportReindexAction.REMOTE_CLUSTER_WHITELIST }); | ||
} | ||
|
||
} |
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
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