Skip to content

Commit

Permalink
[Segment Replication] Fix Flaky test SegmentReplicationRelocationIT.t…
Browse files Browse the repository at this point in the history
…estPrimaryRelocation (opensearch-project#10701)

* Add primary mode check before assserting on primary mode.

Signed-off-by: Rishikesh1159 <[email protected]>

* remove unnecessary shardRouting check.

Signed-off-by: Rishikesh1159 <[email protected]>

* Add test logging.

Signed-off-by: Rishikesh1159 <[email protected]>

* Addressing comments on PR.

Signed-off-by: Rishikesh1159 <[email protected]>

---------

Signed-off-by: Rishikesh1159 <[email protected]>
  • Loading branch information
Rishikesh1159 committed Oct 20, 2023
1 parent 4f8bcff commit 1e9ec52
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.opensearch.index.shard.IndexShard;
import org.opensearch.indices.IndicesService;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.opensearch.test.junit.annotations.TestLogging;
import org.opensearch.test.transport.MockTransportService;
import org.opensearch.transport.TransportService;

Expand Down Expand Up @@ -55,6 +56,7 @@ private void createIndex(int replicaCount) {
* This test verifies happy path when primary shard is relocated newly added node (target) in the cluster. Before
* relocation and after relocation documents are indexed and documents are verified
*/
@TestLogging(reason = "Getting trace logs from replication,shard and allocation package", value = "org.opensearch.indices.replication:TRACE, org.opensearch.index.shard:TRACE, org.opensearch.cluster.routing.allocation:TRACE")
public void testPrimaryRelocation() throws Exception {
final String oldPrimary = internalCluster().startNode();
createIndex(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import org.opensearch.OpenSearchException;
import org.opensearch.action.StepListener;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.cluster.routing.IndexShardRoutingTable;
import org.opensearch.cluster.routing.ShardRouting;
import org.opensearch.common.logging.Loggers;
import org.opensearch.common.util.CancellableThreads;
import org.opensearch.common.util.concurrent.ListenableFuture;
Expand All @@ -22,7 +20,6 @@
import org.opensearch.core.action.ActionListener;
import org.opensearch.index.shard.IndexShard;
import org.opensearch.index.store.StoreFileMetadata;
import org.opensearch.indices.recovery.DelayRecoveryException;
import org.opensearch.indices.recovery.FileChunkWriter;
import org.opensearch.indices.recovery.MultiChunkTransfer;
import org.opensearch.indices.replication.common.CopyState;
Expand Down Expand Up @@ -146,12 +143,6 @@ public synchronized void sendFiles(GetSegmentFilesRequest request, ActionListene
);
};
cancellableThreads.checkForCancel();
final IndexShardRoutingTable routingTable = shard.getReplicationGroup().getRoutingTable();
ShardRouting targetShardRouting = routingTable.getByAllocationId(request.getTargetAllocationId());
if (targetShardRouting == null) {
logger.debug("delaying replication of {} as it is not listed as assigned to target node {}", shard.shardId(), targetNode);
throw new DelayRecoveryException("source node does not have the shard listed in its state as allocated on the node");
}

final StepListener<Void> sendFileStep = new StepListener<>();
Set<String> storeFiles = new HashSet<>(Arrays.asList(shard.store().directory().listAll()));
Expand Down

0 comments on commit 1e9ec52

Please sign in to comment.