Skip to content

Commit 69b5fec

Browse files
authored
Merge branch 'main' into esql-inference-command-serialization
2 parents f5dbc16 + 5f92c44 commit 69b5fec

File tree

19 files changed

+153
-75
lines changed

19 files changed

+153
-75
lines changed

docs/changelog/139244.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 139244
2+
summary: "Inference command: support for CCS"
3+
area: ES|QL
4+
type: enhancement
5+
issues:
6+
- 136860

docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/SystemPrivilege.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public final class SystemPrivilege extends Privilege {
3636
"indices:admin/template/put", // needed for the TemplateUpgradeService
3737
"indices:admin/template/delete", // needed for the TemplateUpgradeService
3838
"indices:admin/seq_no/global_checkpoint_sync*", // needed for global checkpoint syncs
39+
"indices:admin/reshard/split*", // needed for reshard operations
3940
RetentionLeaseSyncAction.ACTION_NAME + "*", // needed for retention lease syncs
4041
RetentionLeaseBackgroundSyncAction.ACTION_NAME + "*", // needed for background retention lease syncs
4142
RetentionLeaseActions.ADD.name() + "*", // needed for CCR to add retention leases

x-pack/plugin/esql/qa/server/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/MixedClusterEsqlSpecIT.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ protected boolean enableRoundingDoubleValuesOnAsserting() {
7575
}
7676

7777
@Override
78-
protected boolean supportsInferenceTestService() {
78+
protected boolean supportsSemanticTextInference() {
79+
return false;
80+
}
81+
82+
@Override
83+
protected boolean supportsInferenceTestServiceOnLocalCluster() {
7984
return false;
8085
}
8186

x-pack/plugin/esql/qa/server/multi-clusters/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ dependencies {
2121
javaRestTestImplementation project(xpackModule('esql:qa:testFixtures'))
2222
javaRestTestImplementation project(xpackModule('esql:qa:server'))
2323
javaRestTestImplementation project(xpackModule('esql'))
24+
25+
clusterPlugins project(':x-pack:plugin:inference:qa:test-service-plugin')
2426
}
2527

2628
def supportedVersion = bwcVersion -> {

x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/Clusters.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public static ElasticsearchCluster localCluster(ElasticsearchCluster remoteClust
5454
if (supportRetryOnShardFailures(version) == false) {
5555
cluster.setting("cluster.routing.rebalance.enable", "none");
5656
}
57+
if (localClusterSupportsInferenceTestService()) {
58+
cluster.plugin("inference-service-test");
59+
}
5760
return cluster.build();
5861
}
5962

@@ -73,6 +76,22 @@ public static org.elasticsearch.Version bwcVersion() {
7376
return local.before(remote) ? local : remote;
7477
}
7578

79+
public static boolean localClusterSupportsInferenceTestService() {
80+
return isNewToOld();
81+
}
82+
83+
/**
84+
* Returns true if the current task is a "newToOld" BWC test.
85+
* Checks the tests.task system property to determine the task type.
86+
*/
87+
private static boolean isNewToOld() {
88+
String taskName = System.getProperty("tests.task");
89+
if (taskName == null) {
90+
return false;
91+
}
92+
return taskName.endsWith("#newToOld");
93+
}
94+
7695
private static Version distributionVersion(String key) {
7796
final String val = System.getProperty(key);
7897
return val != null ? Version.fromString(val) : Version.CURRENT;

x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClusterSpecIT.java

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.CSV_DATASET_MAP;
4949
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.ENRICH_SOURCE_INDICES;
5050
import static org.elasticsearch.xpack.esql.EsqlTestUtils.classpathResources;
51+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.COMPLETION;
5152
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.ENABLE_FORK_FOR_REMOTE_INDICES_V2;
5253
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.ENABLE_LOOKUP_JOIN_ON_REMOTE;
5354
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.FORK_V9;
@@ -56,7 +57,9 @@
5657
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_LOOKUP_V12;
5758
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_PLANNING_V1;
5859
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.METADATA_FIELDS_REMOTE_TEST;
60+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.RERANK;
5961
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.SUBQUERY_IN_FROM_COMMAND;
62+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION;
6063
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.UNMAPPED_FIELDS;
6164
import static org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase.hasCapabilities;
6265
import static org.mockito.ArgumentMatchers.any;
@@ -82,6 +85,12 @@ public class MultiClusterSpecIT extends EsqlSpecTestCase {
8285
private static RestClient remoteClusterClient;
8386
private static DataLocation dataLocation = null;
8487

88+
private static final Set<String> LOCAL_ONLY_INFERENCE_CAPABILITIES = Set.of(
89+
RERANK.capabilityName(),
90+
COMPLETION.capabilityName(),
91+
TEXT_EMBEDDING_FUNCTION.capabilityName()
92+
);
93+
8594
@ParametersFactory(argumentFormatting = "csv-spec:%2$s.%3$s")
8695
public static List<Object[]> readScriptSpec() throws Exception {
8796
List<URL> urls = classpathResources("/*.csv-spec");
@@ -134,8 +143,15 @@ protected void shouldSkipTest(String testName) throws IOException {
134143
.filter(c -> c.equals("metadata_fields_remote_test") == false)
135144
.toList();
136145
}
146+
// Check all capabilities on the local cluster first.
137147
super.shouldSkipTest(testName);
138-
checkCapabilities(remoteClusterClient(), remoteFeaturesService(), testName, testCase);
148+
149+
// Filter out capabilities that are required only on the local cluster and then check the remaining on the remote cluster.
150+
List<String> remoteCapabilities = testCase.requiredCapabilities.stream()
151+
.filter(c -> LOCAL_ONLY_INFERENCE_CAPABILITIES.contains(c) == false)
152+
.toList();
153+
checkCapabilities(remoteClusterClient(), remoteFeaturesService(), testName, remoteCapabilities);
154+
139155
// Do not run tests including "METADATA _index" unless marked with metadata_fields_remote_test,
140156
// because they may produce inconsistent results with multiple clusters.
141157
assumeFalse("can't test with _index metadata", (remoteMetadata == false) && hasIndexMetadata(testCase.query));
@@ -230,10 +246,12 @@ protected RestClient buildClient(Settings settings, HttpHost[] localHosts) throw
230246
.collect(Collectors.toSet());
231247

232248
/**
233-
* Creates a new mock client that dispatches every request to both the local and remote clusters, excluding _bulk and _query requests.
249+
* Creates a new mock client that dispatches every request to both the local and remote clusters, excluding _bulk, _query,
250+
* and _inference requests :
234251
* - '_bulk' requests are randomly sent to either the local or remote cluster to populate data. Some spec tests, such as AVG,
235252
* prevent the splitting of bulk requests.
236253
* - '_query' requests are dispatched to the local cluster only, as we are testing cross-cluster queries.
254+
* - '_inference' requests are dispatched to the local cluster only, as inference endpoints are not available on remote clusters.
237255
*/
238256
static RestClient twoClients(RestClient localClient, RestClient remoteClient) throws IOException {
239257
RestClient twoClients = mock(RestClient.class);
@@ -245,6 +263,8 @@ static RestClient twoClients(RestClient localClient, RestClient remoteClient) th
245263
String endpoint = request.getEndpoint();
246264
if (endpoint.startsWith("/_query")) {
247265
return localClient.performRequest(request);
266+
} else if (endpoint.startsWith("/_inference")) {
267+
return localClient.performRequest(request);
248268
} else if (endpoint.endsWith("/_bulk") && METADATA_INDICES.stream().anyMatch(i -> endpoint.equals("/" + i + "/_bulk"))) {
249269
return remoteClient.performRequest(request);
250270
} else if (endpoint.endsWith("/_bulk")
@@ -340,10 +360,15 @@ protected boolean enableRoundingDoubleValuesOnAsserting() {
340360
}
341361

342362
@Override
343-
protected boolean supportsInferenceTestService() {
363+
protected boolean supportsSemanticTextInference() {
344364
return false;
345365
}
346366

367+
@Override
368+
protected boolean supportsInferenceTestServiceOnLocalCluster() {
369+
return Clusters.localClusterSupportsInferenceTestService();
370+
}
371+
347372
@Override
348373
protected boolean supportsIndexModeLookup() throws IOException {
349374
return hasCapabilities(adminClient(), List.of(JOIN_LOOKUP_V12.capabilityName()));

x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/PushExpressionToLoadIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ protected boolean preserveClusterUponCompletion() {
823823

824824
private void setUpTextEmbeddingInferenceEndpoint() throws IOException {
825825
setupEmbeddings = true;
826-
Request request = new Request("PUT", "_inference/text_embedding/test");
826+
Request request = new Request("PUT", "/_inference/text_embedding/test");
827827
request.setJsonEntity("""
828828
{
829829
"service": "text_embedding_test_service",

x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/PushQueriesIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ public void setUpTextEmbeddingInferenceEndpoint() throws IOException {
548548
return;
549549
}
550550
setupEmbeddings = true;
551-
Request request = new Request("PUT", "_inference/text_embedding/test");
551+
Request request = new Request("PUT", "/_inference/text_embedding/test");
552552
request.setJsonEntity("""
553553
{
554554
"service": "text_embedding_test_service",

0 commit comments

Comments
 (0)