1010import org .apache .lucene .tests .util .LuceneTestCase ;
1111import org .elasticsearch .ExceptionsHelper ;
1212import org .elasticsearch .action .ActionListener ;
13+ import org .elasticsearch .action .admin .indices .stats .IndicesStatsRequest ;
1314import org .elasticsearch .action .bulk .BulkRequestBuilder ;
1415import org .elasticsearch .action .support .WriteRequest ;
1516import org .elasticsearch .cluster .metadata .IndexMetadata ;
@@ -269,6 +270,7 @@ public void testCancelUnnecessaryRequests() {
269270 var coordinatorNodeTransport = MockTransportService .getInstance (coordinatingNode );
270271 coordinatorNodeTransport .addSendBehavior ((connection , requestId , action , request , options ) -> {
271272 if (Objects .equals (action , ExchangeService .OPEN_EXCHANGE_ACTION_NAME )) {
273+ logger .info ("Opening exchange on node [{}]" , connection .getNode ().getId ());
272274 exchanges .incrementAndGet ();
273275 }
274276 connection .sendRequest (requestId , action , request , options );
@@ -282,6 +284,16 @@ public void testCancelUnnecessaryRequests() {
282284 var result = safeExecute (client (coordinatingNode ), EsqlQueryAction .INSTANCE , query );
283285 assertThat (Iterables .size (result .rows ()), equalTo (1L ));
284286 assertThat (exchanges .get (), lessThanOrEqualTo (1 ));// 0 if result is populated from coordinating node
287+ } catch (AssertionError e ) {
288+ client ().admin ().indices ().stats (new IndicesStatsRequest ()).actionGet ().asMap ().forEach ((shard , stats ) -> {
289+ logger .info (
290+ "Shard {} node {} status {} docs {}" ,
291+ shard .shardId (),
292+ shard .currentNodeId (),
293+ shard .state (),
294+ stats .getStats ().getDocs ().getCount ()
295+ );
296+ });
285297 } finally {
286298 coordinatorNodeTransport .clearAllRules ();
287299 }
0 commit comments