@@ -27,61 +27,80 @@ public class RemoteStoreMigrationShardAllocationIT extends RemoteStoreMigrationS
27
27
private Client client ;
28
28
29
29
// test for shard allocation decisions for MIXED mode and NONE direction
30
- public void testAllocationForRemoteStoreBackedIndexForNoneDirectionAndMixedMode () throws Exception {
30
+ public void testAllocationForNoneDirectionAndMixedMode () throws Exception {
31
+ boolean isRemoteStoreBackedIndex = randomBoolean ();
32
+ boolean isReplicaAllocation = randomBoolean ();
33
+ logger .info (
34
+ String .format (
35
+ Locale .ROOT ,
36
+ "Test for allocation decisions for %s shard of a %s store backed index under NONE direction" ,
37
+ (isReplicaAllocation ? "replica" : "primary" ),
38
+ (isRemoteStoreBackedIndex ? "remote" : "non remote" )
39
+ )
40
+ );
41
+
31
42
logger .info ("Initialize cluster" );
32
- initializeCluster (true );
43
+ initializeCluster (isRemoteStoreBackedIndex );
33
44
34
45
logger .info ("Add data nodes" );
35
- String remoteNodeName1 = internalCluster ().startDataOnlyNode ();
36
- String remoteNodeName2 = internalCluster ().startDataOnlyNode ();
46
+ String previousNodeName1 = internalCluster ().startDataOnlyNode ();
47
+ String previousNodeName2 = internalCluster ().startDataOnlyNode ();
37
48
internalCluster ().validateClusterFormed ();
38
- DiscoveryNode remoteNode1 = assertNodeInCluster (remoteNodeName1 );
39
- DiscoveryNode remoteNode2 = assertNodeInCluster (remoteNodeName2 );
49
+ DiscoveryNode previousNode1 = assertNodeInCluster (previousNodeName1 );
50
+ DiscoveryNode previousNode2 = assertNodeInCluster (previousNodeName2 );
40
51
41
52
logger .info ("Prepare test index" );
42
- boolean isReplicaAllocation = randomBoolean ();
43
53
if (isReplicaAllocation ) {
44
- prepareIndexWithAllocatedPrimary (remoteNode1 , Optional .empty ());
54
+ prepareIndexWithAllocatedPrimary (previousNode1 , Optional .empty ());
45
55
} else {
46
56
prepareIndexWithoutReplica (Optional .empty ());
47
57
}
48
- assertRemoteStoreBackedIndex (TEST_INDEX );
58
+
59
+ if (isRemoteStoreBackedIndex ) {
60
+ assertRemoteStoreBackedIndex (TEST_INDEX );
61
+ } else {
62
+ assertNonRemoteStoreBackedIndex (TEST_INDEX );
63
+ }
49
64
50
65
logger .info ("Switch to MIXED cluster compatibility mode" );
51
66
setClusterMode (MIXED .mode );
52
- addRemote = false ;
53
- String docrepNodeName = internalCluster ().startDataOnlyNode ();
67
+ addRemote = ! addRemote ;
68
+ String newNodeName = internalCluster ().startDataOnlyNode ();
54
69
internalCluster ().validateClusterFormed ();
55
- DiscoveryNode docrepNode = assertNodeInCluster (docrepNodeName );
70
+ DiscoveryNode newNode = assertNodeInCluster (newNodeName );
56
71
57
- logger .info ("Verify decision for allocation on docrep node" );
72
+ logger .info ("Verify decision for allocation on the new node" );
58
73
prepareDecisions ();
59
- Decision decision = getDecisionForTargetNode (docrepNode , !isReplicaAllocation , false , false );
74
+ Decision decision = getDecisionForTargetNode (newNode , !isReplicaAllocation , false , false );
60
75
assertEquals (Decision .Type .NO , decision .type ());
61
76
String expectedReason = String .format (
62
77
Locale .ROOT ,
63
- "[none migration_direction]: %s shard copy can not be allocated to a non-remote node for remote store backed index" ,
64
- (isReplicaAllocation ? "replica" : "primary" )
78
+ "[none migration_direction]: %s shard copy can not be allocated to a %s node for %s store backed index" ,
79
+ (isReplicaAllocation ? "replica" : "primary" ),
80
+ (isRemoteStoreBackedIndex ? "non-remote" : "remote" ),
81
+ (isRemoteStoreBackedIndex ? "remote" : "non remote" )
65
82
);
66
83
assertEquals (expectedReason , decision .getExplanation ().toLowerCase (Locale .ROOT ));
67
84
68
- logger .info ("Attempt allocation of shard on non-remote node" );
69
- attemptAllocation (docrepNodeName );
85
+ logger .info ("Attempt allocation of shard on new node" );
86
+ attemptAllocation (newNodeName );
70
87
71
88
logger .info ("Verify non-allocation of shard" );
72
89
assertNonAllocation (!isReplicaAllocation );
73
90
74
- logger .info ("Verify decision for allocation on remote node" );
75
- decision = getDecisionForTargetNode (remoteNode2 , !isReplicaAllocation , true , false );
91
+ logger .info ("Verify decision for allocation on previous node" );
92
+ decision = getDecisionForTargetNode (previousNode2 , !isReplicaAllocation , true , false );
76
93
assertEquals (Decision .Type .YES , decision .type ());
77
94
expectedReason = String .format (
78
95
Locale .ROOT ,
79
- "[none migration_direction]: %s shard copy can be allocated to a remote node for remote store backed index" ,
80
- (isReplicaAllocation ? "replica" : "primary" )
96
+ "[none migration_direction]: %s shard copy can be allocated to a %s node for %s store backed index" ,
97
+ (isReplicaAllocation ? "replica" : "primary" ),
98
+ (isRemoteStoreBackedIndex ? "remote" : "non-remote" ),
99
+ (isRemoteStoreBackedIndex ? "remote" : "non remote" )
81
100
);
82
101
assertEquals (expectedReason , decision .getExplanation ().toLowerCase (Locale .ROOT ));
83
102
84
- logger .info ("Attempt free allocation of shard on remote node " );
103
+ logger .info ("Attempt free allocation of shard" );
85
104
attemptAllocation (null );
86
105
87
106
logger .info ("Verify successful allocation of shard" );
@@ -91,9 +110,11 @@ public void testAllocationForRemoteStoreBackedIndexForNoneDirectionAndMixedMode(
91
110
ensureYellowAndNoInitializingShards (TEST_INDEX );
92
111
}
93
112
assertAllocation (!isReplicaAllocation , null );
94
- logger .info ("Verify allocation on one of the remote nodes" );
113
+ logger .info ("Verify allocation on one of the previous nodes" );
95
114
ShardRouting shardRouting = getShardRouting (!isReplicaAllocation );
96
- assertTrue (shardRouting .currentNodeId ().equals (remoteNode1 .getId ()) || shardRouting .currentNodeId ().equals (remoteNode2 .getId ()));
115
+ assertTrue (
116
+ shardRouting .currentNodeId ().equals (previousNode1 .getId ()) || shardRouting .currentNodeId ().equals (previousNode2 .getId ())
117
+ );
97
118
}
98
119
99
120
// bootstrap a cluster
0 commit comments