From bc8eadc40a1e208e65cd11f0cb15245652ac5a5f Mon Sep 17 00:00:00 2001 From: bansvaru Date: Thu, 31 Aug 2023 23:11:33 +0530 Subject: [PATCH] fixes after local testing Signed-off-by: bansvaru --- .../RemoteStoreClusterStateRestoreIT.java | 45 ++++++++++--------- .../restore/RestoreRemoteStoreRequest.java | 2 +- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreClusterStateRestoreIT.java b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreClusterStateRestoreIT.java index 6068e96b8cae4..10084c4c380fb 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreClusterStateRestoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreClusterStateRestoreIT.java @@ -47,7 +47,7 @@ private void addNewNodes(int dataNodeCount, int clusterManagerNodeCount) { private Map initialTestSetup(int shardCount, int replicaCount, int dataNodeCount, int clusterManagerNodeCount) { prepareCluster(clusterManagerNodeCount, dataNodeCount, INDEX_NAME, replicaCount, shardCount); Map indexStats = indexData(1, false, INDEX_NAME); - assertEquals(shardCount, getNumShards(INDEX_NAME).totalNumShards); + assertEquals(shardCount * (replicaCount + 1), getNumShards(INDEX_NAME).totalNumShards); ensureGreen(INDEX_NAME); return indexStats; } @@ -69,11 +69,7 @@ private void restoreAndValidate( boolean validate, ActionListener actionListener ) throws Exception { - client().admin() - .cluster() - // Any sampleUUID would work as we are not integrated with remote cluster state repo in this test. - // We are mocking that interaction and supplying dummy index metadata - .restoreRemoteStore(new RestoreRemoteStoreRequest().clusterUUID(clusterUUID), actionListener); + client().admin().cluster().restoreRemoteStore(new RestoreRemoteStoreRequest().clusterUUID(clusterUUID), actionListener); if (validate) { // Step - 4 validation restore is successful. @@ -90,7 +86,12 @@ private void restoreAndValidateFails(String clusterUUID, PlainActionFuture indexStats2 = indexData(1, false, secondIndexName); - assertEquals(shardCount + 1, getNumShards(secondIndexName).totalNumShards); + assertEquals((shardCount + 1) * (replicaCount + 1), getNumShards(secondIndexName).totalNumShards); ensureGreen(secondIndexName); String prevClusterUUID = clusterService().state().metadata().clusterUUID(); @@ -150,8 +151,8 @@ public void testFullClusterRestoreMultipleIndices() throws Exception { @AwaitsFix(bugUrl = "waiting upload flow rebase. tested on integration PR") public void testFullClusterRestoreShardLimitReached() throws Exception { int shardCount = randomIntBetween(2, 3); - int replicaCount = 0; - int dataNodeCount = shardCount; + int replicaCount = 1; + int dataNodeCount = shardCount * (replicaCount + 1); int clusterManagerNodeCount = 1; // Step - 1 index some data to generate files in remote directory @@ -209,8 +210,8 @@ public void testFullClusterRestoreShardLimitReached() throws Exception { @AwaitsFix(bugUrl = "waiting upload flow rebase. tested on integration PR") public void testFullClusterRestoreNoStateInRestoreIllegalStateArgumentException() throws Exception { int shardCount = randomIntBetween(1, 2); - int replicaCount = 0; - int dataNodeCount = shardCount; + int replicaCount = 1; + int dataNodeCount = shardCount * (replicaCount + 1); int clusterManagerNodeCount = 1; // Step - 1 index some data to generate files in remote directory @@ -224,8 +225,8 @@ public void testFullClusterRestoreNoStateInRestoreIllegalStateArgumentException( @AwaitsFix(bugUrl = "waiting upload flow rebase. tested on integration PR") public void testRestoreFlowFullClusterOnSameClusterUUID() throws Exception { int shardCount = randomIntBetween(1, 2); - int replicaCount = 0; - int dataNodeCount = shardCount; + int replicaCount = 1; + int dataNodeCount = shardCount * (replicaCount + 1); int clusterManagerNodeCount = 1; // Step - 1 index some data to generate files in remote directory @@ -239,8 +240,8 @@ public void testRestoreFlowFullClusterOnSameClusterUUID() throws Exception { @AwaitsFix(bugUrl = "waiting upload flow rebase. tested on integration PR") public void testFullClusterRestoreSameNameIndexExists() throws Exception { int shardCount = randomIntBetween(1, 2); - int replicaCount = 0; - int dataNodeCount = shardCount; + int replicaCount = 1; + int dataNodeCount = shardCount * (replicaCount + 1); int clusterManagerNodeCount = 1; // Step - 1 index some data to generate files in remote directory @@ -270,8 +271,8 @@ public void testFullClusterRestoreSameNameIndexExists() throws Exception { @AwaitsFix(bugUrl = "waiting upload flow rebase. tested on integration PR") public void testFullClusterRestoreMarkerFilePointsToInvalidIndexMetadataPathIllegalStateArgumentException() throws Exception { int shardCount = randomIntBetween(1, 2); - int replicaCount = 0; - int dataNodeCount = shardCount; + int replicaCount = 1; + int dataNodeCount = shardCount * (replicaCount + 1); int clusterManagerNodeCount = 1; // Step - 1 index some data to generate files in remote directory diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreRequest.java index dc64307c4fbaa..018706c50f6a5 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreRequest.java @@ -63,7 +63,7 @@ public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if ((indices == null || indices.length == 0) && clusterUUID.isEmpty() == true) { validationException = addValidationError("indices are missing", validationException); - } else if ((indices != null || indices.length > 0) && clusterUUID.isEmpty() == false) { + } else if ((indices != null && indices.length > 0) && clusterUUID.isEmpty() == false) { validationException = addValidationError("cannot selectively restore indices during full cluster restore", validationException); } return validationException;