diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java index 9d9f76c9ba185..23afcab7bec7c 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java @@ -128,7 +128,6 @@ private static ListMultimap, String> createLegacyRestTestBasePluginUsag map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ilm:qa:multi-cluster"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ilm:qa:multi-node"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ilm:qa:rest"); - map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:inference:qa:mixed-cluster"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ml:qa:basic-multi-node"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ml:qa:disabled"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ml:qa:ml-with-security"); diff --git a/x-pack/plugin/inference/build.gradle b/x-pack/plugin/inference/build.gradle index 804ac2d591d0c..0aef8601ffcc6 100644 --- a/x-pack/plugin/inference/build.gradle +++ b/x-pack/plugin/inference/build.gradle @@ -27,7 +27,6 @@ base { dependencies { implementation project(path: ':libs:elasticsearch-logging') - testImplementation project(path: ':test:framework') compileOnly project(":server") compileOnly project(path: xpackModule('core')) testImplementation(testArtifact(project(xpackModule('core')))) diff --git a/x-pack/plugin/inference/qa/mixed-cluster/build.gradle b/x-pack/plugin/inference/qa/mixed-cluster/build.gradle index 216b147b94ea9..1d5369468b054 100644 --- a/x-pack/plugin/inference/qa/mixed-cluster/build.gradle +++ b/x-pack/plugin/inference/qa/mixed-cluster/build.gradle @@ -8,15 +8,6 @@ apply plugin: 'elasticsearch.internal-java-rest-test' apply plugin: 'elasticsearch.internal-test-artifact-base' apply plugin: 'elasticsearch.bwc-test' -restResources { - restApi { - include '_common', 'bulk', 'get', 'indices', 'inference', 'xpack', 'cluster' - } - restTests { - includeXpack 'inference' - } -} - dependencies { testImplementation project(path: ':x-pack:plugin:inference:qa:inference-service-tests') compileOnly project(':x-pack:plugin:core') diff --git a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/AzureOpenAiServiceMixedIT.java b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/AzureOpenAiServiceMixedIT.java index bcf1ede6b2d87..1ee1c63c11308 100644 --- a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/AzureOpenAiServiceMixedIT.java +++ b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/AzureOpenAiServiceMixedIT.java @@ -13,8 +13,6 @@ import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.http.MockResponse; import org.elasticsearch.test.http.MockWebServer; -import org.junit.AfterClass; -import org.junit.BeforeClass; import java.io.IOException; import java.util.List; diff --git a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/BaseMixedIT.java b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/BaseMixedIT.java index 2b5b9f3d1066a..3aa7457e16e0d 100644 --- a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/BaseMixedIT.java +++ b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/BaseMixedIT.java @@ -15,10 +15,12 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.inference.TaskType; +import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.cluster.ElasticsearchCluster; import org.elasticsearch.test.cluster.local.distribution.DistributionType; import org.elasticsearch.test.http.MockWebServer; import org.elasticsearch.test.rest.ESRestTestCase; +import org.hamcrest.Matchers; import org.junit.ClassRule; import java.io.IOException; @@ -28,9 +30,8 @@ import static org.elasticsearch.core.Strings.format; import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.hasSize; -public class BaseMixedIT extends ESRestTestCase { +public abstract class BaseMixedIT extends ESRestTestCase { @ClassRule public static ElasticsearchCluster cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) @@ -46,48 +47,48 @@ protected String getTestRestCluster() { } protected static String getUrl(MockWebServer webServer) { - return format("http://%s:%s", webServer.getHostName(), webServer.getPort()); + return Strings.format("http://%s:%s", webServer.getHostName(), webServer.getPort()); } @Override protected Settings restClientSettings() { - String token = basicAuthHeaderValue("x_pack_rest_user", new SecureString("x-pack-test-password".toCharArray())); + String token = ESRestTestCase.basicAuthHeaderValue("x_pack_rest_user", new SecureString("x-pack-test-password".toCharArray())); return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", token).build(); } protected void delete(String inferenceId, TaskType taskType) throws IOException { var request = new Request("DELETE", Strings.format("_inference/%s/%s", taskType, inferenceId)); - var response = client().performRequest(request); - assertOK(response); + var response = ESRestTestCase.client().performRequest(request); + ESRestTestCase.assertOK(response); } protected void delete(String inferenceId) throws IOException { var request = new Request("DELETE", Strings.format("_inference/%s", inferenceId)); - var response = client().performRequest(request); - assertOK(response); + var response = ESRestTestCase.client().performRequest(request); + ESRestTestCase.assertOK(response); } protected Map getAll() throws IOException { var request = new Request("GET", "_inference/_all"); - var response = client().performRequest(request); - assertOK(response); - return entityAsMap(response); + var response = ESRestTestCase.client().performRequest(request); + ESRestTestCase.assertOK(response); + return ESRestTestCase.entityAsMap(response); } protected Map get(String inferenceId) throws IOException { var endpoint = Strings.format("_inference/%s", inferenceId); var request = new Request("GET", endpoint); - var response = client().performRequest(request); - assertOK(response); - return entityAsMap(response); + var response = ESRestTestCase.client().performRequest(request); + ESRestTestCase.assertOK(response); + return ESRestTestCase.entityAsMap(response); } protected Map get(TaskType taskType, String inferenceId) throws IOException { var endpoint = Strings.format("_inference/%s/%s", taskType, inferenceId); var request = new Request("GET", endpoint); - var response = client().performRequest(request); - assertOK(response); - return entityAsMap(response); + var response = ESRestTestCase.client().performRequest(request); + ESRestTestCase.assertOK(response); + return ESRestTestCase.entityAsMap(response); } protected Map inference(String inferenceId, TaskType taskType, String input) throws IOException { @@ -95,9 +96,9 @@ protected Map inference(String inferenceId, TaskType taskType, S var request = new Request("POST", endpoint); request.setJsonEntity("{\"input\": [" + '"' + input + '"' + "]}"); - var response = client().performRequest(request); - assertOK(response); - return entityAsMap(response); + var response = ESRestTestCase.client().performRequest(request); + ESRestTestCase.assertOK(response); + return ESRestTestCase.entityAsMap(response); } protected Map rerank(String inferenceId, List inputs, String query) throws IOException { @@ -116,17 +117,17 @@ protected Map rerank(String inferenceId, List inputs, St body.append("]}"); request.setJsonEntity(body.toString()); - var response = client().performRequest(request); - assertOK(response); - return entityAsMap(response); + var response = ESRestTestCase.client().performRequest(request); + ESRestTestCase.assertOK(response); + return ESRestTestCase.entityAsMap(response); } protected void put(String inferenceId, String modelConfig, TaskType taskType) throws IOException { String endpoint = Strings.format("_inference/%s/%s?error_trace", taskType, inferenceId); var request = new Request("PUT", endpoint); request.setJsonEntity(modelConfig); - var response = client().performRequest(request); - assertOKAndConsume(response); + var response = ESRestTestCase.client().performRequest(request); + ESRestTestCase.assertOKAndConsume(response); logger.warn("PUT response: {}", response.toString()); } @@ -139,6 +140,10 @@ protected static void assertOkOrCreated(Response response) throws IOException { } String responseStr = EntityUtils.toString(response.getEntity()); - assertThat(responseStr, response.getStatusLine().getStatusCode(), anyOf(equalTo(200), equalTo(201))); + ESTestCase.assertThat( + responseStr, + response.getStatusLine().getStatusCode(), + Matchers.anyOf(Matchers.equalTo(200), Matchers.equalTo(201)) + ); } } diff --git a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/Clusters.java b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/Clusters.java index 13e9ea164103f..870d64d7603e5 100644 --- a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/Clusters.java +++ b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/Clusters.java @@ -18,8 +18,6 @@ public static ElasticsearchCluster mixedVersionCluster() { .distribution(DistributionType.DEFAULT) .withNode(node -> node.version(oldVersion)) .withNode(node -> node.version(Version.CURRENT)) - .withNode(node -> node.version(oldVersion)) - .withNode(node -> node.version(Version.CURRENT)) .setting("xpack.security.enabled", "false") .setting("xpack.license.self_generated.type", "trial") .setting("cluster.routing.rebalance.enable", "none") // disable relocation until we have retry in ESQL