Browse Source

Fix RequestIndexFilteringIT::testIndicesDontExist (#120899) (#120909)

Remote cluster is randomly picked by the test. The failure was happening as now we emit a different error when attempting a join with a remote cluster.

(cherry picked from commit 084192c80fe2a793df51c1ea70fa533296894ebc)
Ievgen Degtiarenko 8 months ago
parent
commit
ecc4c92b00

+ 11 - 3
x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RequestIndexFilteringTestCase.java

@@ -13,6 +13,7 @@ import org.elasticsearch.client.Response;
 import org.elasticsearch.client.ResponseException;
 import org.elasticsearch.client.RestClient;
 import org.elasticsearch.test.rest.ESRestTestCase;
+import org.elasticsearch.transport.RemoteClusterAware;
 import org.elasticsearch.xcontent.XContentType;
 import org.elasticsearch.xpack.esql.AssertWarnings;
 import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
@@ -212,13 +213,20 @@ public abstract class RequestIndexFilteringTestCase extends ESRestTestCase {
         assertThat(e.getMessage(), anyOf(containsString("no such index [foo]"), containsString("no such index [remote_cluster:foo]")));
 
         if (EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()) {
+            var pattern = from("test1");
             e = expectThrows(
                 ResponseException.class,
-                () -> runEsql(timestampFilter("gte", "2020-01-01").query(from("test1") + " | LOOKUP JOIN foo ON id1"))
+                () -> runEsql(timestampFilter("gte", "2020-01-01").query(pattern + " | LOOKUP JOIN foo ON id1"))
             );
             assertEquals(400, e.getResponse().getStatusLine().getStatusCode());
-            assertThat(e.getMessage(), containsString("verification_exception"));
-            assertThat(e.getMessage(), containsString("Unknown index [foo]"));
+            assertThat(
+                e.getMessage(),
+                // currently we don't support remote clusters in LOOKUP JOIN
+                // this check happens before resolving actual indices and results in a different error message
+                RemoteClusterAware.isRemoteIndexName(pattern)
+                    ? allOf(containsString("parsing_exception"), containsString("remote clusters are not supported in LOOKUP JOIN"))
+                    : allOf(containsString("verification_exception"), containsString("Unknown index [foo]"))
+            );
         }
     }