@@ -260,6 +260,7 @@ public void testSearchesAgainstNonMatchingIndices() throws Exception {
260
260
Map <String , Object > testClusterInfo = setupClusters (numClusters );
261
261
int localNumShards = (Integer ) testClusterInfo .get ("local.num_shards" );
262
262
int remote1NumShards = (Integer ) testClusterInfo .get ("remote1.num_shards" );
263
+ int remote2NumShards = (Integer ) testClusterInfo .get ("remote2.num_shards" );
263
264
String localIndex = (String ) testClusterInfo .get ("local.index" );
264
265
String remote1Index = (String ) testClusterInfo .get ("remote1.index" );
265
266
String remote2Index = (String ) testClusterInfo .get ("remote2.index" );
@@ -281,7 +282,23 @@ public void testSearchesAgainstNonMatchingIndices() throws Exception {
281
282
{
282
283
String q = "FROM logs*,cluster-a:nomatch" ;
283
284
String expectedError = "Unknown index [cluster-a:nomatch]" ;
285
+ setSkipUnavailable (REMOTE_CLUSTER_1 , false );
284
286
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
+ }
285
302
}
286
303
287
304
// 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 {
411
428
String remote2IndexName = randomFrom (remote2Index , IDX_ALIAS , FILTERED_IDX_ALIAS );
412
429
String q = Strings .format ("FROM %s*,cluster-a:nomatch,%s:%s*" , localIndexName , REMOTE_CLUSTER_2 , remote2IndexName );
413
430
String expectedError = "Unknown index [cluster-a:nomatch]" ;
431
+ setSkipUnavailable (REMOTE_CLUSTER_1 , false );
414
432
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
+ }
415
459
}
416
460
}
417
461
@@ -454,8 +498,8 @@ public void assertExpectedClustersForMissingIndicesTests(EsqlExecutionInfo execu
454
498
assertThat (msg , cluster .getSkippedShards (), equalTo (expectedCluster .totalShards ()));
455
499
assertThat (msg , cluster .getFailures ().size (), equalTo (1 ));
456
500
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 () ));
459
503
hasSkipped = true ;
460
504
}
461
505
// 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 {
809
853
assertTrue (latch .await (30 , TimeUnit .SECONDS ));
810
854
}
811
855
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
813
857
public void testRemoteFailureSkipUnavailableTrue () throws IOException {
814
858
Map <String , Object > testClusterInfo = setupFailClusters ();
815
859
String localIndex = (String ) testClusterInfo .get ("local.index" );
816
860
String remote1Index = (String ) testClusterInfo .get ("remote.index" );
817
861
String q = Strings .format ("FROM %s,cluster-a:%s*" , localIndex , remote1Index );
818
862
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 ));
821
868
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
+ }
824
880
}
825
881
826
882
private static void assertClusterMetadataInResponse (EsqlQueryResponse resp , boolean responseExpectMeta ) {
0 commit comments