@@ -183,12 +183,8 @@ public void testFailedAllocation() {
183
183
assertThat (unassignedPrimary .unassignedInfo ().getMessage (), containsString ("boom" + i ));
184
184
// MaxRetryAllocationDecider#canForceAllocatePrimary should return YES decisions because canAllocate returns YES here
185
185
assertEquals (
186
- Decision .YES ,
187
- new MaxRetryAllocationDecider ().canForceAllocatePrimary (
188
- unassignedPrimary ,
189
- null ,
190
- new RoutingAllocation (null , clusterState , null , null , 0 )
191
- )
186
+ Decision .Type .YES ,
187
+ new MaxRetryAllocationDecider ().canForceAllocatePrimary (unassignedPrimary , null , newRoutingAllocation (clusterState )).type ()
192
188
);
193
189
}
194
190
// now we go and check that we are actually stick to unassigned on the next failure
@@ -207,12 +203,8 @@ public void testFailedAllocation() {
207
203
assertThat (unassignedPrimary .unassignedInfo ().getMessage (), containsString ("boom" ));
208
204
// MaxRetryAllocationDecider#canForceAllocatePrimary should return a NO decision because canAllocate returns NO here
209
205
assertEquals (
210
- Decision .NO ,
211
- new MaxRetryAllocationDecider ().canForceAllocatePrimary (
212
- unassignedPrimary ,
213
- null ,
214
- new RoutingAllocation (null , clusterState , null , null , 0 )
215
- )
206
+ Decision .Type .NO ,
207
+ new MaxRetryAllocationDecider ().canForceAllocatePrimary (unassignedPrimary , null , newRoutingAllocation (clusterState )).type ()
216
208
);
217
209
}
218
210
@@ -247,12 +239,12 @@ public void testFailedAllocation() {
247
239
assertThat (unassignedPrimary .unassignedInfo ().getMessage (), containsString ("boom" ));
248
240
// bumped up the max retry count, so canForceAllocatePrimary should return a YES decision
249
241
assertEquals (
250
- Decision .YES ,
242
+ Decision .Type . YES ,
251
243
new MaxRetryAllocationDecider ().canForceAllocatePrimary (
252
244
routingTable .index ("idx" ).shard (0 ).shard (0 ),
253
245
null ,
254
- new RoutingAllocation ( null , clusterState , null , null , 0 )
255
- )
246
+ newRoutingAllocation ( clusterState )
247
+ ). type ()
256
248
);
257
249
258
250
// now we start the shard
@@ -279,13 +271,17 @@ public void testFailedAllocation() {
279
271
assertThat (unassignedPrimary .unassignedInfo ().getMessage (), containsString ("ZOOOMG" ));
280
272
// Counter reset, so MaxRetryAllocationDecider#canForceAllocatePrimary should return a YES decision
281
273
assertEquals (
282
- Decision .YES ,
283
- new MaxRetryAllocationDecider ().canForceAllocatePrimary (
284
- unassignedPrimary ,
285
- null ,
286
- new RoutingAllocation (null , clusterState , null , null , 0 )
287
- )
274
+ Decision .Type .YES ,
275
+ new MaxRetryAllocationDecider ().canForceAllocatePrimary (unassignedPrimary , null , newRoutingAllocation (clusterState )).type ()
288
276
);
289
277
}
290
278
279
+ private RoutingAllocation newRoutingAllocation (ClusterState clusterState ) {
280
+ final var routingAllocation = new RoutingAllocation (null , clusterState , null , null , 0 );
281
+ if (randomBoolean ()) {
282
+ routingAllocation .setDebugMode (randomFrom (RoutingAllocation .DebugMode .values ()));
283
+ }
284
+ return routingAllocation ;
285
+ }
286
+
291
287
}
0 commit comments