Skip to content

Commit

Permalink
Add Tests. Spotless fix
Browse files Browse the repository at this point in the history
Signed-off-by: pranikum <[email protected]>
  • Loading branch information
pranikum committed Sep 7, 2022
1 parent 93d662d commit 88ed486
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fix NoSuchFileExceptions with segment replication when computing primary metadata snapshots ([#4366](https://github.com/opensearch-project/OpenSearch/pull/4366))
- [Segment Replication] Update flaky testOnNewCheckpointFromNewPrimaryCancelOngoingReplication unit test ([#4414](https://github.com/opensearch-project/OpenSearch/pull/4414))
- Fixed the `_cat/shards/10_basic.yml` test cases fix.
- Recommissioning of zone. REST layer support. ([#4321](https://github.com/opensearch-project/OpenSearch/pull/4321))

### Security
- CVE-2022-25857 org.yaml:snakeyaml DOS vulnerability ([#4341](https://github.com/opensearch-project/OpenSearch/pull/4341))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,8 @@ public void testApiNamingConventions() throws Exception {
"nodes.usage",
"nodes.reload_secure_settings",
"search_shards",
"remote_store.restore", };
"remote_store.restore",
"cluster.delete_decommission_awareness"};
List<String> booleanReturnMethods = Arrays.asList("security.enable_user", "security.disable_user", "security.change_password");
Set<String> deprecatedMethods = new HashSet<>();
deprecatedMethods.add("indices.force_merge");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"cluster.delete_decommission_awareness": {
"documentation": {
"url": "https://opensearch.org/docs/latest/opensearch/rest-api/decommission/",
"description": "Delete any existing decommission."
},
"stability": "experimental",
"url": {
"paths": [
{
"path": "/_cluster/decommission/awareness/",
"methods": [
"DELETE"
]
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import org.opensearch.action.support.clustermanager.ClusterManagerNodeOperationRequestBuilder;
import org.opensearch.client.OpenSearchClient;
import org.opensearch.cluster.decommission.DecommissionAttribute;
import org.opensearch.common.unit.TimeValue;

public class DeleteDecommissionRequestBuilder extends ClusterManagerNodeOperationRequestBuilder<
DeleteDecommissionRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

public class DeleteDecommissionResponse extends AcknowledgedResponse implements ToXContentObject {

DeleteDecommissionResponse(StreamInput in) throws IOException {
public DeleteDecommissionResponse(StreamInput in) throws IOException {
super(in);
}

DeleteDecommissionResponse(boolean acknowledged) {
public DeleteDecommissionResponse(boolean acknowledged) {
super(acknowledged);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.action.ActionListener;
import org.opensearch.action.admin.cluster.configuration.TransportClearVotingConfigExclusionsAction;
import org.opensearch.action.support.ActionFilters;
import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction;
import org.opensearch.cluster.ClusterState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ public String getName() {

@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
DeleteDecommissionRequest deleteDecommissionRequest = Requests.deleteDecommissionRequest();
DeleteDecommissionRequest deleteDecommissionRequest = createRequest();
return channel -> client.admin().cluster().deleteDecommission(deleteDecommissionRequest, new RestToXContentListener<>(channel));
}

DeleteDecommissionRequest createRequest() {
return Requests.deleteDecommissionRequest();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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.action.admin.cluster.decommission.awareness;

import org.opensearch.action.admin.cluster.decommission.awareness.delete.DeleteDecommissionRequest;
import org.opensearch.test.OpenSearchTestCase;

import java.io.IOException;

public class DeleteDecommissionRequestTests extends OpenSearchTestCase {

public void testSerialization() throws IOException {
final DeleteDecommissionRequest originalRequest = new DeleteDecommissionRequest();

final DeleteDecommissionRequest deserialized = copyWriteable(originalRequest, writableRegistry(), DeleteDecommissionRequest::new);
assertEquals(deserialized, originalRequest);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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.action.admin.cluster.decommission.awareness;

import org.opensearch.action.admin.cluster.decommission.awareness.delete.DeleteDecommissionResponse;
import org.opensearch.test.OpenSearchTestCase;

import java.io.IOException;

public class DeleteDecommissionResponseTests extends OpenSearchTestCase {

public void testSerialization() throws IOException {
final DeleteDecommissionResponse originalResponse = new DeleteDecommissionResponse(true);

final DeleteDecommissionResponse deserialized = copyWriteable(
originalResponse,
writableRegistry(),
DeleteDecommissionResponse::new
);
assertEquals(deserialized, originalResponse);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
import org.opensearch.test.rest.FakeRestRequest;
import org.opensearch.test.rest.RestActionTestCase;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RestDeleteDecommissionActionTests extends RestActionTestCase {

Expand All @@ -37,8 +35,7 @@ public void testRoutes() {
}

public void testCreateRequest() {
RestRequest deprecatedRequest = buildRestRequest();
DeleteDecommissionRequest request = action.createRequest(deprecatedRequest);
DeleteDecommissionRequest request = action.createRequest();
assertNotNull(request);
}

Expand Down

0 comments on commit 88ed486

Please sign in to comment.