Skip to content

Commit

Permalink
fixes after local testing
Browse files Browse the repository at this point in the history
Signed-off-by: bansvaru <[email protected]>
  • Loading branch information
linuxpi committed Aug 31, 2023
1 parent 793ece8 commit bc8eadc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void addNewNodes(int dataNodeCount, int clusterManagerNodeCount) {
private Map<String, Long> initialTestSetup(int shardCount, int replicaCount, int dataNodeCount, int clusterManagerNodeCount) {
prepareCluster(clusterManagerNodeCount, dataNodeCount, INDEX_NAME, replicaCount, shardCount);
Map<String, Long> 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;
}
Expand All @@ -69,11 +69,7 @@ private void restoreAndValidate(
boolean validate,
ActionListener<RestoreRemoteStoreResponse> 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.
Expand All @@ -90,7 +86,12 @@ private void restoreAndValidateFails(String clusterUUID, PlainActionFuture<Resto
RestoreRemoteStoreResponse response = actionListener.get();
} catch (ExecutionException e) {
// If the request goes to co-ordinator, e.getCause() can be RemoteTransportException
assertTrue(e.getCause() instanceof IllegalStateException || e.getCause().getCause() instanceof IllegalStateException);
assertTrue(
e.getCause() instanceof IllegalStateException
|| e.getCause().getCause() instanceof IllegalStateException
|| e.getCause() instanceof IllegalArgumentException
|| e.getCause().getCause() instanceof IllegalArgumentException
);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Expand All @@ -99,8 +100,8 @@ private void restoreAndValidateFails(String clusterUUID, PlainActionFuture<Resto
@AwaitsFix(bugUrl = "waiting upload flow rebase. tested on integration PR")
public void testFullClusterRestore() 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
Expand All @@ -120,8 +121,8 @@ public void testFullClusterRestore() throws Exception {
@AwaitsFix(bugUrl = "waiting upload flow rebase. tested on integration PR")
public void testFullClusterRestoreMultipleIndices() throws Exception {
int shardCount = randomIntBetween(1, 2);
int replicaCount = 0;
int dataNodeCount = shardCount + 1;
int replicaCount = 1;
int dataNodeCount = shardCount * (replicaCount + 1);
int clusterManagerNodeCount = 1;

// Step - 1 index some data to generate files in remote directory
Expand All @@ -130,7 +131,7 @@ public void testFullClusterRestoreMultipleIndices() throws Exception {
String secondIndexName = INDEX_NAME + "-2";
createIndex(secondIndexName, remoteStoreIndexSettings(replicaCount, shardCount + 1));
Map<String, Long> 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();
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bc8eadc

Please sign in to comment.