Skip to content

Commit

Permalink
Change order of an import
Browse files Browse the repository at this point in the history
Signed-off-by: Tianli Feng <ftianli@amazon.com>
  • Loading branch information
Tianli Feng committed Apr 2, 2022
1 parent 36f4637 commit 7e6abf9
Showing 1 changed file with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.opensearch.client.node.NodeClient;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.common.settings.Settings;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.action.cat.RestAllocationAction;
import org.opensearch.rest.action.cat.RestRepositoriesAction;
import org.opensearch.rest.action.cat.RestThreadPoolAction;
Expand All @@ -27,8 +28,6 @@
import org.opensearch.rest.action.cat.RestPendingClusterTasksAction;
import org.opensearch.rest.action.cat.RestSegmentsAction;
import org.opensearch.rest.action.cat.RestSnapshotAction;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.action.cat.RestNodesAction;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.test.rest.FakeRestRequest;
import org.opensearch.threadpool.TestThreadPool;
Expand All @@ -47,9 +46,9 @@ public class RenamedTimeoutRequestParameterTests extends OpenSearchTestCase {
private final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RenamedTimeoutRequestParameterTests.class);

private static final String DUPLICATE_PARAMETER_ERROR_MESSAGE =
"Please only use one of the request parameters [master_timeout, cluster_manager_timeout].";
"Please only use one of the request parameters [master_timeout, cluster_manager_timeout].";
private static final String MASTER_TIMEOUT_DEPRECATED_MESSAGE =
"Deprecated parameter [master_timeout] used. To promote inclusive language, please use [cluster_manager_timeout] instead. It will be unsupported in a future major version.";
"Deprecated parameter [master_timeout] used. To promote inclusive language, please use [cluster_manager_timeout] instead. It will be unsupported in a future major version.";

@After
public void terminateThreadPool() {
Expand All @@ -58,32 +57,32 @@ public void terminateThreadPool() {

public void testNoWarningsForNewParam() {
BaseRestHandler.parseDeprecatedMasterTimeoutParameter(
getMasterNodeRequest(),
getRestRequestWithNewParam(),
deprecationLogger,
"test"
getMasterNodeRequest(),
getRestRequestWithNewParam(),
deprecationLogger,
"test"
);
}

public void testDeprecationWarningForOldParam() {
BaseRestHandler.parseDeprecatedMasterTimeoutParameter(
getMasterNodeRequest(),
getRestRequestWithDeprecatedParam(),
deprecationLogger,
"test"
getMasterNodeRequest(),
getRestRequestWithDeprecatedParam(),
deprecationLogger,
"test"
);
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
}

public void testBothParamsNotValid() {
Exception e = assertThrows(
OpenSearchParseException.class,
() -> BaseRestHandler.parseDeprecatedMasterTimeoutParameter(
getMasterNodeRequest(),
getRestRequestWithBothParams(),
deprecationLogger,
"test"
)
OpenSearchParseException.class,
() -> BaseRestHandler.parseDeprecatedMasterTimeoutParameter(
getMasterNodeRequest(),
getRestRequestWithBothParams(),
deprecationLogger,
"test"
)
);
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
Expand Down

0 comments on commit 7e6abf9

Please sign in to comment.