Skip to content

Commit 50cb08a

Browse files
committed
Adding more assertions to ITs and removing unintended changes
Signed-off-by: Shourya Dutta Biswas <114977491+shourya035@users.noreply.github.com>
1 parent 6875ca7 commit 50cb08a

File tree

5 files changed

+14
-29
lines changed

5 files changed

+14
-29
lines changed

server/src/internalClusterTest/java/org/opensearch/remotemigration/DocrepToRemoteDualReplicationIT.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,17 @@ public void testRemotePrimaryDocRepAndRemoteReplica() throws Exception {
197197
assertReplicaAndPrimaryConsistencyMultiCopy(shardStatsMap, firstBatch, secondBatch, nodes);
198198
}
199199

200+
/*
201+
Scenario:
202+
- Starts 1 docrep backed data node
203+
- Creates an index with 0 replica
204+
- Starts 1 remote backed data node
205+
- Move primary copy from docrep to remote through _cluster/reroute
206+
- Expands index to 1 replica
207+
- Stops remote enabled node
208+
- Ensure doc count is same after failover
209+
- Index some more docs to ensure working of failed-over primary
210+
*/
200211
public void testFailoverRemotePrimaryToDocrepReplica() throws Exception {
201212
internalCluster().setBootstrapClusterManagerNodeIndex(0);
202213
internalCluster().startClusterManagerOnlyNode();
@@ -268,6 +279,7 @@ public void testFailoverRemotePrimaryToDocrepReplica() throws Exception {
268279
long initialPrimaryDocCount = 0;
269280
for (ShardRouting shardRouting : shardStatsMap.keySet()) {
270281
if (shardRouting.primary()) {
282+
assertTrue(nodes.get(shardRouting.currentNodeId()).isRemoteStoreNode());
271283
initialPrimaryDocCount = shardStatsMap.get(shardRouting).getStats().getDocs().getCount();
272284
}
273285
}
@@ -279,10 +291,11 @@ public void testFailoverRemotePrimaryToDocrepReplica() throws Exception {
279291
ensureYellow(FAILOVER_REMOTE_TO_DOCREP);
280292

281293
shardStatsMap = internalCluster().client().admin().indices().prepareStats(FAILOVER_REMOTE_TO_DOCREP).setDocs(true).get().asMap();
282-
DiscoveryNodes discoveryNodes = internalCluster().client().admin().cluster().prepareState().get().getState().getNodes();
294+
nodes = internalCluster().client().admin().cluster().prepareState().get().getState().getNodes();
283295
long primaryDocCountAfterFailover = 0;
284296
for (ShardRouting shardRouting : shardStatsMap.keySet()) {
285297
if (shardRouting.primary()) {
298+
assertFalse(nodes.get(shardRouting.currentNodeId()).isRemoteStoreNode());
286299
primaryDocCountAfterFailover = shardStatsMap.get(shardRouting).getStats().getDocs().getCount();
287300
}
288301
}

server/src/main/java/org/opensearch/index/remote/RemoteStoreUtils.java

-20
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,14 @@
88

99
package org.opensearch.index.remote;
1010

11-
import org.opensearch.cluster.service.ClusterService;
1211
import org.opensearch.common.collect.Tuple;
13-
import org.opensearch.node.remotestore.RemoteStoreNodeService;
1412

1513
import java.util.Arrays;
1614
import java.util.HashMap;
1715
import java.util.List;
1816
import java.util.Map;
1917
import java.util.function.Function;
2018

21-
import static org.opensearch.node.remotestore.RemoteStoreNodeService.MIGRATION_DIRECTION_SETTING;
22-
import static org.opensearch.node.remotestore.RemoteStoreNodeService.REMOTE_STORE_COMPATIBILITY_MODE_SETTING;
23-
2419
/**
2520
* Utils for remote store
2621
*
@@ -105,19 +100,4 @@ public static void verifyNoMultipleWriters(List<String> mdFiles, Function<String
105100
}
106101
});
107102
}
108-
109-
/**
110-
* Helper method to check the values for the following cluster settings:
111-
* - `remote_store.compatibility_mode` (should be `mixed`)
112-
* - `migration.direction` (should NOT be `none`)
113-
* Used as a source of truth to confirm if a remote store migration is in progress
114-
* @param clusterService Current clusterService ref to fetch cluster settings
115-
*/
116-
public static boolean isMigrationDirectionSet(ClusterService clusterService) {
117-
RemoteStoreNodeService.Direction migrationDirection = clusterService.getClusterSettings().get(MIGRATION_DIRECTION_SETTING);
118-
RemoteStoreNodeService.CompatibilityMode currentCompatiblityMode = clusterService.getClusterSettings()
119-
.get(REMOTE_STORE_COMPATIBILITY_MODE_SETTING);
120-
return currentCompatiblityMode.equals(RemoteStoreNodeService.CompatibilityMode.MIXED) == true
121-
&& migrationDirection.equals(RemoteStoreNodeService.Direction.NONE) == false;
122-
}
123103
}

server/src/main/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncAction.java

-3
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ protected Logger getLogger() {
8888
return LOGGER;
8989
}
9090

91-
private final ClusterService clusterService;
92-
9391
@Inject
9492
public RetentionLeaseBackgroundSyncAction(
9593
final Settings settings,
@@ -113,7 +111,6 @@ public RetentionLeaseBackgroundSyncAction(
113111
Request::new,
114112
ThreadPool.Names.MANAGEMENT
115113
);
116-
this.clusterService = clusterService;
117114
}
118115

119116
@Override

server/src/main/java/org/opensearch/index/seqno/RetentionLeaseSyncAction.java

-3
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ protected Logger getLogger() {
9090
return LOGGER;
9191
}
9292

93-
private final ClusterService clusterService;
94-
9593
@Inject
9694
public RetentionLeaseSyncAction(
9795
final Settings settings,
@@ -122,7 +120,6 @@ public RetentionLeaseSyncAction(
122120
systemIndices,
123121
tracer
124122
);
125-
this.clusterService = clusterService;
126123
}
127124

128125
@Override

server/src/main/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointAction.java

-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public class PublishCheckpointAction extends TransportReplicationAction<
5858
protected static Logger logger = LogManager.getLogger(PublishCheckpointAction.class);
5959

6060
private final SegmentReplicationTargetService replicationService;
61-
private final ClusterService clusterService;
6261

6362
@Inject
6463
public PublishCheckpointAction(
@@ -85,7 +84,6 @@ public PublishCheckpointAction(
8584
ThreadPool.Names.REFRESH
8685
);
8786
this.replicationService = targetService;
88-
this.clusterService = clusterService;
8987
}
9088

9189
@Override

0 commit comments

Comments
 (0)