@@ -66,24 +66,34 @@ public void beforeIndexShardCreated(ShardRouting routing, Settings indexSettings
66
66
assertThat (shardAfterFailures .state (), equalTo (ShardRoutingState .STARTED ));
67
67
assertThat (stateAfterFailures .nodes ().get (shardAfterFailures .currentNodeId ()).getName (), equalTo (node1 ));
68
68
failRelocation .set (false );
69
- // A non-RESTART node shutdown should reset the counter and allow more relocation retries
70
- final var request = createRequest (randomFrom (SingleNodeShutdownMetadata .Type .values ()), node1 , node2 );
71
- client ().execute (PutShutdownNodeAction .INSTANCE , request ).get ();
72
- if (request .getType () != SingleNodeShutdownMetadata .Type .RESTART ) {
73
- assertBusy (() -> {
74
- var stateAfterNodeJoin = internalCluster ().clusterService ().state ();
75
- var relocatedShard = stateAfterNodeJoin .routingTable ().index ("index1" ).shard (0 ).primaryShard ();
76
- assertThat (relocatedShard .relocationFailureInfo ().failedRelocations (), Matchers .lessThan (maxAttempts ));
77
- assertThat (relocatedShard , notNullValue ());
78
- assertThat (stateAfterNodeJoin .nodes ().get (relocatedShard .currentNodeId ()).getName (), not (equalTo (node1 )));
79
- });
80
- } else {
69
+ if (randomBoolean ()) {
70
+ // A RESTART marker shouldn't cause a reset of failures
71
+ final var request = createRequest (SingleNodeShutdownMetadata .Type .RESTART , node1 , null );
72
+ client ().execute (PutShutdownNodeAction .INSTANCE , request ).get ();
81
73
var state = clusterAdmin ().prepareState (TEST_REQUEST_TIMEOUT ).get ().getState ();
82
74
var shard = state .routingTable ().index ("index1" ).shard (0 ).primaryShard ();
83
75
assertThat (shard , notNullValue ());
84
76
assertThat (shard .relocationFailureInfo ().failedRelocations (), equalTo (maxAttempts ));
85
77
assertThat (state .nodes ().get (shard .currentNodeId ()).getName (), equalTo (node1 ));
86
78
}
79
+ // A non-RESTART node shutdown should reset the counter and allow more relocation retries
80
+ final var request = createRequest (
81
+ randomFrom (
82
+ SingleNodeShutdownMetadata .Type .REPLACE ,
83
+ SingleNodeShutdownMetadata .Type .SIGTERM ,
84
+ SingleNodeShutdownMetadata .Type .REMOVE
85
+ ),
86
+ node1 ,
87
+ node2
88
+ );
89
+ client ().execute (PutShutdownNodeAction .INSTANCE , request ).get ();
90
+ assertBusy (() -> {
91
+ var stateAfterNodeJoin = internalCluster ().clusterService ().state ();
92
+ var relocatedShard = stateAfterNodeJoin .routingTable ().index ("index1" ).shard (0 ).primaryShard ();
93
+ assertThat (relocatedShard .relocationFailureInfo ().failedRelocations (), Matchers .lessThan (maxAttempts ));
94
+ assertThat (relocatedShard , notNullValue ());
95
+ assertThat (stateAfterNodeJoin .nodes ().get (relocatedShard .currentNodeId ()).getName (), not (equalTo (node1 )));
96
+ });
87
97
}
88
98
89
99
public void testResetRelocationFailuresOnNodeShutdownRemovalOfExistingNode () throws Exception {
@@ -178,19 +188,30 @@ public void beforeIndexShardCreated(ShardRouting routing, Settings indexSettings
178
188
179
189
failAllocation .set (false );
180
190
181
- // A non-RESTART node shutdown should reset the counter and allow more relocation retries
182
- final var request = createRequest (randomFrom (SingleNodeShutdownMetadata .Type .values ()), node1 , node2 );
183
- client ().execute (PutShutdownNodeAction .INSTANCE , request ).get ();
184
- if (request .getType () != SingleNodeShutdownMetadata .Type .RESTART ) {
185
- ensureGreen ("index1" );
186
- } else {
191
+ if (randomBoolean ()) {
192
+ // A RESTART marker shouldn't cause a reset of failures
193
+ final var request = createRequest (randomFrom (SingleNodeShutdownMetadata .Type .RESTART ), node1 , null );
194
+ client ().execute (PutShutdownNodeAction .INSTANCE , request ).get ();
187
195
ensureRed ("index1" );
188
196
var state = clusterAdmin ().prepareState (TEST_REQUEST_TIMEOUT ).get ().getState ();
189
197
var shard = state .routingTable ().index ("index1" ).shard (0 ).primaryShard ();
190
198
assertThat (shard , notNullValue ());
191
199
assertNotNull (shard .unassignedInfo ());
192
200
assertThat (shard .unassignedInfo ().failedAllocations (), equalTo (maxAttempts ));
193
201
}
202
+
203
+ // A non-RESTART node shutdown should reset the counter and allow more relocation retries
204
+ final var request = createRequest (
205
+ randomFrom (
206
+ SingleNodeShutdownMetadata .Type .REPLACE ,
207
+ SingleNodeShutdownMetadata .Type .SIGTERM ,
208
+ SingleNodeShutdownMetadata .Type .REMOVE
209
+ ),
210
+ node1 ,
211
+ node2
212
+ );
213
+ client ().execute (PutShutdownNodeAction .INSTANCE , request ).get ();
214
+ ensureGreen ("index1" );
194
215
}
195
216
196
217
public void testResetAllocationFailuresOnNodeShutdownRemovalOfExistingNode () throws Exception {
0 commit comments