126
126
import static org .mockito .Matchers .anyLong ;
127
127
import static org .mockito .Matchers .anyObject ;
128
128
import static org .mockito .Matchers .anyString ;
129
+ import static org .mockito .Matchers .eq ;
129
130
import static org .mockito .Mockito .doAnswer ;
130
131
import static org .mockito .Mockito .doThrow ;
131
132
import static org .mockito .Mockito .mock ;
@@ -152,6 +153,7 @@ public static <R extends ReplicationRequest> R resolveRequest(TransportRequest r
152
153
153
154
private static ThreadPool threadPool ;
154
155
156
+ private boolean forceExecute ;
155
157
private ClusterService clusterService ;
156
158
private TransportService transportService ;
157
159
private CapturingTransport transport ;
@@ -172,6 +174,7 @@ public static void beforeClass() {
172
174
@ Before
173
175
public void setUp () throws Exception {
174
176
super .setUp ();
177
+ forceExecute = randomBoolean ();
175
178
transport = new CapturingTransport ();
176
179
clusterService = createClusterService (threadPool );
177
180
transportService = transport .createTransportService (clusterService .getSettings (), threadPool ,
@@ -839,7 +842,7 @@ public void testSeqNoIsSetOnPrimary() {
839
842
//noinspection unchecked
840
843
((ActionListener <Releasable >)invocation .getArguments ()[0 ]).onResponse (count ::decrementAndGet );
841
844
return null ;
842
- }).when (shard ).acquirePrimaryOperationPermit (any (), anyString (), anyObject ());
845
+ }).when (shard ).acquirePrimaryOperationPermit (any (), anyString (), anyObject (), eq ( forceExecute ) );
843
846
when (shard .getActiveOperationsCount ()).thenAnswer (i -> count .get ());
844
847
845
848
final IndexService indexService = mock (IndexService .class );
@@ -1272,7 +1275,7 @@ private class TestAction extends TransportReplicationAction<Request, Request, Te
1272
1275
super (settings , actionName , transportService , clusterService , indicesService , threadPool ,
1273
1276
shardStateAction ,
1274
1277
new ActionFilters (new HashSet <>()),
1275
- Request ::new , Request ::new , ThreadPool .Names .SAME );
1278
+ Request ::new , Request ::new , ThreadPool .Names .SAME , false , forceExecute );
1276
1279
}
1277
1280
1278
1281
@ Override
@@ -1343,7 +1346,7 @@ private IndexShard mockIndexShard(ShardId shardId, ClusterService clusterService
1343
1346
callback .onFailure (new ShardNotInPrimaryModeException (shardId , IndexShardState .STARTED ));
1344
1347
}
1345
1348
return null ;
1346
- }).when (indexShard ).acquirePrimaryOperationPermit (any (ActionListener .class ), anyString (), anyObject ());
1349
+ }).when (indexShard ).acquirePrimaryOperationPermit (any (ActionListener .class ), anyString (), anyObject (), eq ( forceExecute ) );
1347
1350
doAnswer (invocation -> {
1348
1351
long term = (Long )invocation .getArguments ()[0 ];
1349
1352
ActionListener <Releasable > callback = (ActionListener <Releasable >) invocation .getArguments ()[3 ];
0 commit comments