@@ -338,7 +338,14 @@ public void testOnPhaseFailureAndVerifyListeners() {
338
338
SearchQueryThenFetchAsyncAction action = createSearchQueryThenFetchAsyncAction (requestOperationListeners );
339
339
action .start ();
340
340
assertEquals (1 , testListener .getPhaseCurrent (action .getSearchPhaseName ()));
341
- action .onPhaseFailure (new SearchPhase ("test" ) {
341
+ action .onPhaseFailure (new SearchPhase ("none" ) {
342
+ @ Override
343
+ public void run () {
344
+
345
+ }
346
+ }, "message" , null );
347
+ assertEquals (1 , testListener .getPhaseCurrent (action .getSearchPhaseName ()));
348
+ action .onPhaseFailure (new SearchPhase (action .getName ()) {
342
349
@ Override
343
350
public void run () {
344
351
@@ -352,14 +359,14 @@ public void run() {
352
359
);
353
360
searchDfsQueryThenFetchAsyncAction .start ();
354
361
assertEquals (1 , testListener .getPhaseCurrent (searchDfsQueryThenFetchAsyncAction .getSearchPhaseName ()));
355
- searchDfsQueryThenFetchAsyncAction .onPhaseFailure (new SearchPhase ("test" ) {
362
+ searchDfsQueryThenFetchAsyncAction .onPhaseFailure (new SearchPhase (searchDfsQueryThenFetchAsyncAction . getName () ) {
356
363
@ Override
357
364
public void run () {
358
365
359
366
}
360
367
}, "message" , null );
361
- assertEquals (0 , testListener .getPhaseCurrent (action .getSearchPhaseName ()));
362
- assertEquals (0 , testListener .getPhaseTotal (action .getSearchPhaseName ()));
368
+ assertEquals (0 , testListener .getPhaseCurrent (searchDfsQueryThenFetchAsyncAction .getSearchPhaseName ()));
369
+ assertEquals (0 , testListener .getPhaseTotal (searchDfsQueryThenFetchAsyncAction .getSearchPhaseName ()));
363
370
364
371
FetchSearchPhase fetchPhase = createFetchSearchPhase ();
365
372
ShardId shardId = new ShardId (randomAlphaOfLengthBetween (5 , 10 ), randomAlphaOfLength (10 ), randomInt ());
@@ -368,7 +375,7 @@ public void run() {
368
375
action .skipShard (searchShardIterator );
369
376
action .executeNextPhase (action , fetchPhase );
370
377
assertEquals (1 , testListener .getPhaseCurrent (fetchPhase .getSearchPhaseName ()));
371
- action .onPhaseFailure (new SearchPhase ("test" ) {
378
+ action .onPhaseFailure (new SearchPhase (fetchPhase . getName () ) {
372
379
@ Override
373
380
public void run () {
374
381
@@ -403,6 +410,30 @@ public void run() {
403
410
assertEquals (requestIds , releasedContexts );
404
411
}
405
412
413
+ public void testOnPhaseStart () {
414
+ ClusterSettings clusterSettings = new ClusterSettings (Settings .EMPTY , ClusterSettings .BUILT_IN_CLUSTER_SETTINGS );
415
+ SearchRequestStats testListener = new SearchRequestStats (clusterSettings );
416
+
417
+ final List <SearchRequestOperationsListener > requestOperationListeners = new ArrayList <>(List .of (testListener ));
418
+ SearchQueryThenFetchAsyncAction action = createSearchQueryThenFetchAsyncAction (requestOperationListeners );
419
+
420
+ action .onPhaseStart (new SearchPhase ("test" ) {
421
+ @ Override
422
+ public void run () {}
423
+ });
424
+ action .onPhaseStart (new SearchPhase ("none" ) {
425
+ @ Override
426
+ public void run () {}
427
+ });
428
+ assertEquals (0 , testListener .getPhaseCurrent (action .getSearchPhaseName ()));
429
+
430
+ action .onPhaseStart (new SearchPhase (action .getName ()) {
431
+ @ Override
432
+ public void run () {}
433
+ });
434
+ assertEquals (1 , testListener .getPhaseCurrent (action .getSearchPhaseName ()));
435
+ }
436
+
406
437
public void testShardNotAvailableWithDisallowPartialFailures () {
407
438
SearchRequest searchRequest = new SearchRequest ().allowPartialSearchResults (false );
408
439
AtomicReference <Exception > exception = new AtomicReference <>();
0 commit comments