@@ -197,6 +197,17 @@ public void testRemotePrimaryDocRepAndRemoteReplica() throws Exception {
197
197
assertReplicaAndPrimaryConsistencyMultiCopy (shardStatsMap , firstBatch , secondBatch , nodes );
198
198
}
199
199
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
+ */
200
211
public void testFailoverRemotePrimaryToDocrepReplica () throws Exception {
201
212
internalCluster ().setBootstrapClusterManagerNodeIndex (0 );
202
213
internalCluster ().startClusterManagerOnlyNode ();
@@ -268,6 +279,7 @@ public void testFailoverRemotePrimaryToDocrepReplica() throws Exception {
268
279
long initialPrimaryDocCount = 0 ;
269
280
for (ShardRouting shardRouting : shardStatsMap .keySet ()) {
270
281
if (shardRouting .primary ()) {
282
+ assertTrue (nodes .get (shardRouting .currentNodeId ()).isRemoteStoreNode ());
271
283
initialPrimaryDocCount = shardStatsMap .get (shardRouting ).getStats ().getDocs ().getCount ();
272
284
}
273
285
}
@@ -279,10 +291,11 @@ public void testFailoverRemotePrimaryToDocrepReplica() throws Exception {
279
291
ensureYellow (FAILOVER_REMOTE_TO_DOCREP );
280
292
281
293
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 ();
283
295
long primaryDocCountAfterFailover = 0 ;
284
296
for (ShardRouting shardRouting : shardStatsMap .keySet ()) {
285
297
if (shardRouting .primary ()) {
298
+ assertFalse (nodes .get (shardRouting .currentNodeId ()).isRemoteStoreNode ());
286
299
primaryDocCountAfterFailover = shardStatsMap .get (shardRouting ).getStats ().getDocs ().getCount ();
287
300
}
288
301
}
0 commit comments