1717import org .apache .lucene .search .IndexSearcher ;
1818import org .apache .lucene .store .Directory ;
1919import org .apache .lucene .tests .index .RandomIndexWriter ;
20+ import org .elasticsearch .cluster .ClusterName ;
2021import org .elasticsearch .common .settings .Settings ;
2122import org .elasticsearch .common .util .BigArrays ;
2223import org .elasticsearch .compute .lucene .LuceneSourceOperator ;
2930import org .elasticsearch .index .IndexMode ;
3031import org .elasticsearch .index .cache .query .TrivialQueryCachingPolicy ;
3132import org .elasticsearch .index .mapper .MapperServiceTestCase ;
33+ import org .elasticsearch .node .Node ;
3234import org .elasticsearch .search .internal .AliasFilter ;
3335import org .elasticsearch .search .internal .ContextIndexSearcher ;
3436import org .elasticsearch .xpack .esql .core .expression .FieldAttribute ;
@@ -159,6 +161,29 @@ public void testLuceneTopNSourceOperatorDistanceSort() throws IOException {
159161 assertThat (factory .limit (), equalTo (10 ));
160162 }
161163
164+ public void testDriverClusterAndNodeName () throws IOException {
165+ int estimatedRowSize = randomEstimatedRowSize (estimatedRowSizeIsHuge );
166+ LocalExecutionPlanner .LocalExecutionPlan plan = planner ().plan (
167+ "test" ,
168+ FoldContext .small (),
169+ new EsQueryExec (
170+ Source .EMPTY ,
171+ index ().name (),
172+ IndexMode .STANDARD ,
173+ index ().indexNameWithModes (),
174+ List .of (),
175+ null ,
176+ null ,
177+ null ,
178+ estimatedRowSize
179+ )
180+ );
181+ assertThat (plan .driverFactories .size (), lessThanOrEqualTo (pragmas .taskConcurrency ()));
182+ LocalExecutionPlanner .DriverSupplier supplier = plan .driverFactories .get (0 ).driverSupplier ();
183+ assertThat (supplier .clusterName (), equalTo ("dev-cluster" ));
184+ assertThat (supplier .nodeName (), equalTo ("node-1" ));
185+ }
186+
162187 private int randomEstimatedRowSize (boolean huge ) {
163188 int hugeBoundary = SourceOperator .MIN_TARGET_PAGE_SIZE * 10 ;
164189 return huge ? between (hugeBoundary , Integer .MAX_VALUE ) : between (1 , hugeBoundary );
@@ -179,7 +204,10 @@ private LocalExecutionPlanner planner() throws IOException {
179204 null ,
180205 BigArrays .NON_RECYCLING_INSTANCE ,
181206 TestBlockFactory .getNonBreakingInstance (),
182- Settings .EMPTY ,
207+ Settings .builder ()
208+ .put (ClusterName .CLUSTER_NAME_SETTING .getKey (), "dev-cluster" )
209+ .put (Node .NODE_NAME_SETTING .getKey (), "node-1" )
210+ .build (),
183211 config (),
184212 null ,
185213 null ,
0 commit comments