@@ -183,12 +183,8 @@ public void testFailedAllocation() {
183183 assertThat (unassignedPrimary .unassignedInfo ().getMessage (), containsString ("boom" + i ));
184184 // MaxRetryAllocationDecider#canForceAllocatePrimary should return YES decisions because canAllocate returns YES here
185185 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 ()
192188 );
193189 }
194190 // now we go and check that we are actually stick to unassigned on the next failure
@@ -207,12 +203,8 @@ public void testFailedAllocation() {
207203 assertThat (unassignedPrimary .unassignedInfo ().getMessage (), containsString ("boom" ));
208204 // MaxRetryAllocationDecider#canForceAllocatePrimary should return a NO decision because canAllocate returns NO here
209205 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 ()
216208 );
217209 }
218210
@@ -247,12 +239,12 @@ public void testFailedAllocation() {
247239 assertThat (unassignedPrimary .unassignedInfo ().getMessage (), containsString ("boom" ));
248240 // bumped up the max retry count, so canForceAllocatePrimary should return a YES decision
249241 assertEquals (
250- Decision .YES ,
242+ Decision .Type . YES ,
251243 new MaxRetryAllocationDecider ().canForceAllocatePrimary (
252244 routingTable .index ("idx" ).shard (0 ).shard (0 ),
253245 null ,
254- new RoutingAllocation ( null , clusterState , null , null , 0 )
255- )
246+ newRoutingAllocation ( clusterState )
247+ ). type ()
256248 );
257249
258250 // now we start the shard
@@ -279,13 +271,17 @@ public void testFailedAllocation() {
279271 assertThat (unassignedPrimary .unassignedInfo ().getMessage (), containsString ("ZOOOMG" ));
280272 // Counter reset, so MaxRetryAllocationDecider#canForceAllocatePrimary should return a YES decision
281273 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 ()
288276 );
289277 }
290278
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+
291287}
0 commit comments