@@ -260,6 +260,7 @@ public void testSearchesAgainstNonMatchingIndices() throws Exception {
260260 Map <String , Object > testClusterInfo = setupClusters (numClusters );
261261 int localNumShards = (Integer ) testClusterInfo .get ("local.num_shards" );
262262 int remote1NumShards = (Integer ) testClusterInfo .get ("remote1.num_shards" );
263+ int remote2NumShards = (Integer ) testClusterInfo .get ("remote2.num_shards" );
263264 String localIndex = (String ) testClusterInfo .get ("local.index" );
264265 String remote1Index = (String ) testClusterInfo .get ("remote1.index" );
265266 String remote2Index = (String ) testClusterInfo .get ("remote2.index" );
@@ -281,7 +282,23 @@ public void testSearchesAgainstNonMatchingIndices() throws Exception {
281282 {
282283 String q = "FROM logs*,cluster-a:nomatch" ;
283284 String expectedError = "Unknown index [cluster-a:nomatch]" ;
285+ setSkipUnavailable (REMOTE_CLUSTER_1 , false );
284286 expectVerificationExceptionForQuery (q , expectedError , requestIncludeMeta );
287+ setSkipUnavailable (REMOTE_CLUSTER_1 , true );
288+ try (EsqlQueryResponse resp = runQuery (q , requestIncludeMeta )) {
289+ assertThat (getValuesList (resp ).size (), greaterThanOrEqualTo (1 ));
290+ EsqlExecutionInfo executionInfo = resp .getExecutionInfo ();
291+ assertThat (executionInfo .isCrossClusterSearch (), is (true ));
292+ assertThat (executionInfo .includeCCSMetadata (), equalTo (responseExpectMeta ));
293+ assertExpectedClustersForMissingIndicesTests (
294+ executionInfo ,
295+ List .of (
296+ new ExpectedCluster (LOCAL_CLUSTER , "logs*" , EsqlExecutionInfo .Cluster .Status .SUCCESSFUL , localNumShards ),
297+ new ExpectedCluster (REMOTE_CLUSTER_1 , "nomatch" , EsqlExecutionInfo .Cluster .Status .SKIPPED , 0 )
298+ )
299+ );
300+
301+ }
285302 }
286303
287304 // No error since local non-matching index has wildcard and the remote cluster index expression matches
@@ -411,7 +428,34 @@ public void testSearchesAgainstNonMatchingIndices() throws Exception {
411428 String remote2IndexName = randomFrom (remote2Index , IDX_ALIAS , FILTERED_IDX_ALIAS );
412429 String q = Strings .format ("FROM %s*,cluster-a:nomatch,%s:%s*" , localIndexName , REMOTE_CLUSTER_2 , remote2IndexName );
413430 String expectedError = "Unknown index [cluster-a:nomatch]" ;
431+ setSkipUnavailable (REMOTE_CLUSTER_1 , false );
414432 expectVerificationExceptionForQuery (q , expectedError , requestIncludeMeta );
433+ setSkipUnavailable (REMOTE_CLUSTER_1 , true );
434+ try (EsqlQueryResponse resp = runQuery (q , requestIncludeMeta )) {
435+ assertThat (getValuesList (resp ).size (), greaterThanOrEqualTo (1 ));
436+ EsqlExecutionInfo executionInfo = resp .getExecutionInfo ();
437+ assertThat (executionInfo .isCrossClusterSearch (), is (true ));
438+ assertThat (executionInfo .includeCCSMetadata (), equalTo (responseExpectMeta ));
439+ assertExpectedClustersForMissingIndicesTests (
440+ executionInfo ,
441+ List .of (
442+ new ExpectedCluster (
443+ LOCAL_CLUSTER ,
444+ "alias-filtered-1*" ,
445+ EsqlExecutionInfo .Cluster .Status .SUCCESSFUL ,
446+ localNumShards
447+ ),
448+ new ExpectedCluster (REMOTE_CLUSTER_1 , "nomatch" , EsqlExecutionInfo .Cluster .Status .SKIPPED , 0 ),
449+ new ExpectedCluster (
450+ REMOTE_CLUSTER_2 ,
451+ remote2IndexName + "*" ,
452+ EsqlExecutionInfo .Cluster .Status .SUCCESSFUL ,
453+ remote2NumShards
454+ )
455+ )
456+ );
457+
458+ }
415459 }
416460 }
417461
@@ -454,8 +498,8 @@ public void assertExpectedClustersForMissingIndicesTests(EsqlExecutionInfo execu
454498 assertThat (msg , cluster .getSkippedShards (), equalTo (expectedCluster .totalShards ()));
455499 assertThat (msg , cluster .getFailures ().size (), equalTo (1 ));
456500 assertThat (msg , cluster .getFailures ().get (0 ).getCause (), instanceOf (VerificationException .class ));
457- String expectedMsg = "Unknown index [" + expectedCluster . indexExpression () + "]" ;
458- assertThat (msg , cluster .getFailures ().get (0 ).getCause ().getMessage (), containsString (expectedMsg ));
501+ assertThat ( msg , cluster . getFailures (). get ( 0 ). getCause (). getMessage (), containsString ( "Unknown index" )) ;
502+ assertThat (msg , cluster .getFailures ().get (0 ).getCause ().getMessage (), containsString (expectedCluster . indexExpression () ));
459503 hasSkipped = true ;
460504 }
461505 // currently failed shards is always zero - change this once we start allowing partial data for individual shard failures
@@ -809,18 +853,30 @@ public void testWarnings() throws Exception {
809853 assertTrue (latch .await (30 , TimeUnit .SECONDS ));
810854 }
811855
812- // Non-disconnect remote failures still fail the request even if skip_unavailable is true
856+ // Non-disconnect remote failures lead to skipping if skip_unavailable is true
813857 public void testRemoteFailureSkipUnavailableTrue () throws IOException {
814858 Map <String , Object > testClusterInfo = setupFailClusters ();
815859 String localIndex = (String ) testClusterInfo .get ("local.index" );
816860 String remote1Index = (String ) testClusterInfo .get ("remote.index" );
817861 String q = Strings .format ("FROM %s,cluster-a:%s*" , localIndex , remote1Index );
818862
819- Exception error = expectThrows (Exception .class , () -> runQuery (q , false ));
820- error = EsqlTestUtils .unwrapIfWrappedInRemoteException (error );
863+ try (EsqlQueryResponse resp = runQuery (q , randomBoolean ())) {
864+ EsqlExecutionInfo executionInfo = resp .getExecutionInfo ();
865+ assertNotNull (executionInfo );
866+ assertThat (executionInfo .isCrossClusterSearch (), is (true ));
867+ assertThat (executionInfo .overallTook ().millis (), greaterThanOrEqualTo (0L ));
821868
822- assertThat (error , instanceOf (IllegalStateException .class ));
823- assertThat (error .getMessage (), containsString ("Accessing failing field" ));
869+ EsqlExecutionInfo .Cluster remoteCluster = executionInfo .getCluster (REMOTE_CLUSTER_1 );
870+ assertThat (remoteCluster .getIndexExpression (), equalTo ("logs-2*" ));
871+ assertThat (remoteCluster .getStatus (), equalTo (EsqlExecutionInfo .Cluster .Status .SKIPPED ));
872+ assertThat (remoteCluster .getTook ().millis (), greaterThanOrEqualTo (0L ));
873+ assertThat (remoteCluster .getTotalShards (), equalTo (0 ));
874+ assertThat (remoteCluster .getSuccessfulShards (), equalTo (0 ));
875+ assertThat (remoteCluster .getSkippedShards (), equalTo (0 ));
876+ assertThat (remoteCluster .getFailedShards (), equalTo (0 ));
877+ assertThat (remoteCluster .getFailures (), hasSize (1 ));
878+ assertThat (remoteCluster .getFailures ().getFirst ().reason (), containsString ("Accessing failing field" ));
879+ }
824880 }
825881
826882 private static void assertClusterMetadataInResponse (EsqlQueryResponse resp , boolean responseExpectMeta ) {
0 commit comments