Skip to content

Commit

Permalink
Ensure graceful test cleanup, Fix assertion in ReplicationTracker
Browse files Browse the repository at this point in the history
Signed-off-by: Bhumika Saini <[email protected]>
  • Loading branch information
Bhumika Saini committed Apr 23, 2024
1 parent b1a2ada commit 5788287
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0)
public class RemotePrimaryLocalRecoveryIT extends MigrationBaseTestCase {
String indexName = "idx1";
int numOfNodes = randomIntBetween(4, 9);
int numOfNodes = randomIntBetween(6, 9);

/**
* Tests local recovery sanity in the happy path flow
*/
public void testLocalRecoveryRollingRestart() throws Exception {
triggerRollingRestartForRemoteMigration(0);
internalCluster().stopAllNodes();
}

/**
Expand All @@ -53,7 +54,7 @@ public void testLocalRecoveryRollingRestartAndNodeFailure() throws Exception {
triggerRollingRestartForRemoteMigration(0);

DiscoveryNodes discoveryNodes = internalCluster().client().admin().cluster().prepareState().get().getState().getNodes();
DiscoveryNode nodeToRestart = (DiscoveryNode) discoveryNodes.getDataNodes().values().toArray()[randomIntBetween(0, numOfNodes - 2)];
DiscoveryNode nodeToRestart = (DiscoveryNode) discoveryNodes.getDataNodes().values().toArray()[randomIntBetween(0, numOfNodes - 4)];
internalCluster().restartNode(nodeToRestart.getName());

Map<ShardRouting, ShardStats> shardStatsMap = internalCluster().client().admin().indices().prepareStats(indexName).get().asMap();
Expand Down Expand Up @@ -90,21 +91,24 @@ public void testLocalRecoveryRollingRestartAndNodeFailure() throws Exception {
);
}, 90, TimeUnit.SECONDS);
}

internalCluster().stopAllNodes();
}

/**
* Tests local recovery flow sanity in the happy path flow with replicas in place
*/
public void testLocalRecoveryFlowWithReplicas() throws Exception {
triggerRollingRestartForRemoteMigration(randomIntBetween(1, 2));
internalCluster().stopAllNodes();
}

/**
* Helper method to run a rolling restart for migration to remote backed cluster
*/
private void triggerRollingRestartForRemoteMigration(int replicaCount) throws Exception {
internalCluster().startNodes(numOfNodes - 1);
internalCluster().startClusterManagerOnlyNode();
internalCluster().startClusterManagerOnlyNodes(3);
internalCluster().startNodes(numOfNodes - 3);

// create index
Settings indexSettings = Settings.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ private ReplicationGroup calculateReplicationGroup() {
} else {
newVersion = replicationGroup.getVersion() + 1;
}
assert indexSettings.isRemoteTranslogStoreEnabled()
assert indexSettings.isAssignedOnRemoteNode()
// Handle migration cases. Ignore assertion if any of the shard copies in the replication group is assigned to a remote node
|| (replicationGroup != null
&& replicationGroup.getReplicationTargets()
Expand Down

0 comments on commit 5788287

Please sign in to comment.