41
41
import org .elasticsearch .index .query .QueryBuilders ;
42
42
import org .elasticsearch .persistent .PersistentTasksCustomMetadata ;
43
43
import org .elasticsearch .plugins .Plugin ;
44
- import org .elasticsearch .search .SearchService ;
45
44
import org .elasticsearch .search .builder .SearchSourceBuilder ;
46
45
import org .elasticsearch .tasks .RemovedTaskListener ;
47
46
import org .elasticsearch .tasks .Task ;
82
81
import static java .util .Collections .singleton ;
83
82
import static org .elasticsearch .action .admin .cluster .node .tasks .TestTaskPlugin .TEST_TASK_ACTION ;
84
83
import static org .elasticsearch .action .admin .cluster .node .tasks .TestTaskPlugin .UNBLOCK_TASK_ACTION ;
84
+ import static org .elasticsearch .action .search .SearchQueryThenFetchAsyncAction .NODE_SEARCH_ACTION_NAME ;
85
+ import static org .elasticsearch .action .search .SearchTransportService .FREE_CONTEXT_SCROLL_ACTION_NAME ;
85
86
import static org .elasticsearch .core .TimeValue .timeValueMillis ;
86
87
import static org .elasticsearch .core .TimeValue .timeValueSeconds ;
87
88
import static org .elasticsearch .http .HttpTransportSettings .SETTING_HTTP_MAX_HEADER_SIZE ;
@@ -353,8 +354,6 @@ public void testTransportBulkTasks() {
353
354
}
354
355
355
356
public void testSearchTaskDescriptions () {
356
- // TODO: enhance this test to also check the tasks created by batched query execution
357
- updateClusterSettings (Settings .builder ().put (SearchService .BATCHED_QUERY_PHASE .getKey (), false ));
358
357
registerTaskManagerListeners (TransportSearchAction .TYPE .name ()); // main task
359
358
registerTaskManagerListeners (TransportSearchAction .TYPE .name () + "[*]" ); // shard task
360
359
createIndex ("test" );
@@ -380,6 +379,11 @@ public void testSearchTaskDescriptions() {
380
379
// check that if we have any shard-level requests they all have non-zero length description
381
380
List <TaskInfo > shardTasks = findEvents (TransportSearchAction .TYPE .name () + "[*]" , Tuple ::v1 );
382
381
for (TaskInfo taskInfo : shardTasks ) {
382
+ // During batched query execution, if a partial reduction was done on the data node, a task will be created to free the reader.
383
+ // These tasks don't have descriptions or parent tasks, so they're ignored for this test.
384
+ if (taskInfo .action ().equals (FREE_CONTEXT_SCROLL_ACTION_NAME )) {
385
+ continue ;
386
+ }
383
387
assertThat (taskInfo .parentTaskId (), notNullValue ());
384
388
assertEquals (mainTask .get (0 ).taskId (), taskInfo .parentTaskId ());
385
389
assertTaskHeaders (taskInfo );
@@ -396,12 +400,12 @@ public void testSearchTaskDescriptions() {
396
400
taskInfo .description (),
397
401
Regex .simpleMatch ("id[*], size[1], lastEmittedDoc[null]" , taskInfo .description ())
398
402
);
403
+ case NODE_SEARCH_ACTION_NAME -> assertEquals ("NodeQueryRequest" , taskInfo .description ());
399
404
default -> fail ("Unexpected action [" + taskInfo .action () + "] with description [" + taskInfo .description () + "]" );
400
405
}
401
406
// assert that all task descriptions have non-zero length
402
407
assertThat (taskInfo .description ().length (), greaterThan (0 ));
403
408
}
404
- updateClusterSettings (Settings .builder ().putNull (SearchService .BATCHED_QUERY_PHASE .getKey ()));
405
409
}
406
410
407
411
public void testSearchTaskHeaderLimit () {
0 commit comments