@@ -50,7 +50,7 @@ public class RemoteStoreMigrationAllocationIT extends MigrationBaseTestCase {
50
50
51
51
// tests for primary shard copy allocation with MIXED mode and REMOTE_STORE direction
52
52
53
- public void testDontAllocateNewPrimaryShardOnNonRemoteNodeForMixedModeAndRemoteStoreDirection () throws Exception {
53
+ public void testAllocateNewPrimaryShardForMixedModeAndRemoteStoreDirection () throws Exception {
54
54
logger .info (" --> initialize cluster" );
55
55
initializeCluster (false );
56
56
@@ -71,59 +71,29 @@ public void testDontAllocateNewPrimaryShardOnNonRemoteNodeForMixedModeAndRemoteS
71
71
setDirection (REMOTE_STORE .direction );
72
72
73
73
Decision decision = getDecisionForTargetNode (nonRemoteNode , true , true , false );
74
- Decision .Type type = Decision .Type .NO ;
75
- assertEquals (type , decision .type ());
74
+ assertEquals (Decision .Type .NO , decision .type ());
76
75
assertEquals (
77
76
"[remote_store migration_direction]: primary shard copy can not be allocated to a non-remote node" ,
78
77
decision .getExplanation ().toLowerCase (Locale .ROOT )
79
78
);
80
79
81
- logger .info (" --> attempt allocation" );
80
+ logger .info (" --> attempt allocation on non-remote node " );
82
81
attemptAllocation (nonRemoteNodeName );
83
82
84
- logger .info (" --> verify non-allocation of primary shard" );
83
+ logger .info (" --> verify non-allocation of primary shard on non-remote node " );
85
84
assertNonAllocation (true );
86
- }
87
-
88
- public void testAllocateNewPrimaryShardOnRemoteNodeForMixedModeAndRemoteStoreDirection () throws Exception {
89
- logger .info (" --> initialize cluster" );
90
- initializeCluster (false );
91
-
92
- logger .info (" --> add remote and non-remote nodes" );
93
- setClusterMode (MIXED .mode );
94
- addRemote = true ;
95
- String remoteNodeName = internalCluster ().startNode ();
96
- addRemote = false ;
97
- String nonRemoteNodeName = internalCluster ().startNode ();
98
- internalCluster ().validateClusterFormed ();
99
- DiscoveryNode remoteNode = assertNodeInCluster (remoteNodeName );
100
- DiscoveryNode nonRemoteNode = assertNodeInCluster (nonRemoteNodeName );
101
85
102
86
logger .info (" --> verify expected decision for allocating a new primary shard on a remote node" );
103
- prepareIndexWithoutReplica (Optional .empty ());
104
-
105
- logger .info (" --> set remote_store direction" );
106
- setDirection (REMOTE_STORE .direction );
107
-
108
- Decision decision = getDecisionForTargetNode (remoteNode , true , true , false );
87
+ prepareDecisions ();
88
+ decision = getDecisionForTargetNode (remoteNode , true , true , false );
109
89
assertEquals (Decision .Type .YES , decision .type ());
110
90
assertEquals (
111
91
"[remote_store migration_direction]: primary shard copy can be allocated to a remote node" ,
112
92
decision .getExplanation ().toLowerCase (Locale .ROOT )
113
93
);
114
94
115
- logger .info (" --> attempt allocation" );
116
- client .admin ()
117
- .indices ()
118
- .prepareUpdateSettings (TEST_INDEX )
119
- .setSettings (
120
- Settings .builder ()
121
- .put ("index.routing.allocation.include._name" , allNodesExcept (null ))
122
- .put ("index.routing.allocation.exclude._name" , "" )
123
- )
124
- .execute ()
125
- .actionGet ();
126
-
95
+ logger .info (" --> attempt allocation on remote node" );
96
+ attemptAllocation (remoteNodeName );
127
97
ensureGreen (TEST_INDEX );
128
98
129
99
logger .info (" --> verify allocation of primary shard" );
@@ -236,11 +206,11 @@ public void testAllocateNewReplicaShardOnNonRemoteNodeIfPrimaryShardOnNonRemoteN
236
206
logger .info (" --> verify expected decision for replica shard" );
237
207
prepareDecisions ();
238
208
Decision decision = getDecisionForTargetNode (nonRemoteNode2 , false , true , false );
239
- Decision .Type type = Decision .Type .YES ;
240
- String reason = "[remote_store migration_direction]: replica shard copy can be allocated to a non-remote node" ;
209
+ Decision .Type expectedType = Decision .Type .YES ;
210
+ String expectedReason = "[remote_store migration_direction]: replica shard copy can be allocated to a non-remote node" ;
241
211
242
- assertEquals (type , decision .type ());
243
- assertEquals (reason , decision .getExplanation ().toLowerCase (Locale .ROOT ));
212
+ assertEquals (expectedType , decision .type ());
213
+ assertEquals (expectedReason , decision .getExplanation ().toLowerCase (Locale .ROOT ));
244
214
245
215
logger .info (" --> allocate replica shard on the other non-remote node" );
246
216
attemptAllocation (nonRemoteNodeName2 );
@@ -276,8 +246,8 @@ public void testAllocateNewReplicaShardOnNonRemoteNodeIfPrimaryShardOnRemoteNode
276
246
prepareDecisions ();
277
247
Decision decision = getDecisionForTargetNode (nonRemoteNode , false , true , false );
278
248
279
- Decision .Type type = Decision .Type .YES ;
280
- assertEquals (type , decision .type ());
249
+ Decision .Type expectedType = Decision .Type .YES ;
250
+ assertEquals (expectedType , decision .type ());
281
251
assertEquals (
282
252
"[remote_store migration_direction]: replica shard copy can be allocated to a non-remote node" ,
283
253
decision .getExplanation ().toLowerCase (Locale .ROOT )
@@ -352,13 +322,13 @@ public void testAlwaysAllocateNewShardForStrictMode() throws Exception {
352
322
prepareDecisions ();
353
323
Decision decision = getDecisionForTargetNode (targetNode , !isReplicaAllocation , true , false );
354
324
assertEquals (Decision .Type .YES , decision .type ());
355
- String reason = String .format (
325
+ String expectedReason = String .format (
356
326
Locale .ROOT ,
357
327
"[remote_store migration_direction]: %s shard copy can be allocated to a %s node for strict compatibility mode" ,
358
328
(isReplicaAllocation ? "replica" : "primary" ),
359
329
(isRemoteCluster ? "remote" : "non-remote" )
360
330
);
361
- assertEquals (reason , decision .getExplanation ().toLowerCase (Locale .ROOT ));
331
+ assertEquals (expectedReason , decision .getExplanation ().toLowerCase (Locale .ROOT ));
362
332
363
333
logger .info (" --> attempt allocation" );
364
334
attemptAllocation (targetNode .getName ());
@@ -410,12 +380,12 @@ public void testDontAllocateToNonRemoteNodeForRemoteStoreBackedIndex() throws Ex
410
380
prepareDecisions ();
411
381
Decision decision = getDecisionForTargetNode (nonRemoteNode , !isReplicaAllocation , false , false );
412
382
assertEquals (Decision .Type .NO , decision .type ());
413
- String reason = String .format (
383
+ String expectedReason = String .format (
414
384
Locale .ROOT ,
415
385
"[remote_store migration_direction]: %s shard copy can not be allocated to a non-remote node because a remote store backed index's shard copy can only be allocated to a remote node" ,
416
386
(isReplicaAllocation ? "replica" : "primary" )
417
387
);
418
- assertEquals (reason , decision .getExplanation ().toLowerCase (Locale .ROOT ));
388
+ assertEquals (expectedReason , decision .getExplanation ().toLowerCase (Locale .ROOT ));
419
389
420
390
logger .info (" --> attempt allocation of shard on non-remote node" );
421
391
attemptAllocation (nonRemoteNodeName );
0 commit comments