From fc54d88fb4447c28ab160cf86bd8e6b316ecdde6 Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Mon, 10 Mar 2025 15:29:58 +0100 Subject: [PATCH] [Tests] Simplify classpath for analytics javaRestTests (#124274) This replaces the usage of a defaultDistribution for javaRestTest by the integTestDistribution. This has a few advantages: 1. The overall dependencies on running the java rest tests are minimized. By using the default distribution we rely on building the whole default distribution (including all modules and plugins) before we can run these tests. This a) takes time and b) dramatically reduces the likelyhood of us avoiding test task execution at all as we basically declare the whole distro as an input. By using integTest distro we reduce the surface of the inputs dramatically which also results in faster execution of these tests 2. its more idiomatic as one pattern we see is that we e.g disable the security settings that we would not need once we use the integTest distro without the security plugin 3. it makes test setup and its dependencies more explicit. Point 3. might sound as like a downside at first, but for understanding what those tests are doing and what they are relying on I think its worth the 3 more lines of code. Here are two build scans task executions: - before the `javaRestTest` task requires `995 tasks, 2 transforms executed in 155 projects`: https://gradle-enterprise.elastic.co/s/drj5mfzsfx7ra/timeline - after we only rely on `275 tasks, 2 transforms executed in 56 projects`: https://gradle-enterprise.elastic.co/s/jr5sblhppn4fg/timeline?page=2 --- x-pack/plugin/analytics/build.gradle | 7 +++---- .../java/org/elasticsearch/multiterms/AggsTimeoutIT.java | 9 +++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/x-pack/plugin/analytics/build.gradle b/x-pack/plugin/analytics/build.gradle index b69e9f0ec3ec2..ca8030ae3a1dd 100644 --- a/x-pack/plugin/analytics/build.gradle +++ b/x-pack/plugin/analytics/build.gradle @@ -19,11 +19,10 @@ base { archivesName = 'x-pack-analytics' } -tasks.named('javaRestTest') { - usesDefaultDistribution() -} - dependencies { + clusterModules project(':modules:aggregations') + clusterPlugins project(':x-pack:plugin:analytics') + api 'org.apache.commons:commons-math3:3.6.1' compileOnly project(path: xpackModule('core')) compileOnly project(":server") diff --git a/x-pack/plugin/analytics/src/javaRestTest/java/org/elasticsearch/multiterms/AggsTimeoutIT.java b/x-pack/plugin/analytics/src/javaRestTest/java/org/elasticsearch/multiterms/AggsTimeoutIT.java index 6ca7d38d87842..57bfc5f52ba09 100644 --- a/x-pack/plugin/analytics/src/javaRestTest/java/org/elasticsearch/multiterms/AggsTimeoutIT.java +++ b/x-pack/plugin/analytics/src/javaRestTest/java/org/elasticsearch/multiterms/AggsTimeoutIT.java @@ -53,12 +53,9 @@ public class AggsTimeoutIT extends ESRestTestCase { @ClassRule public static ElasticsearchCluster cluster = ElasticsearchCluster.local() - .distribution(DistributionType.DEFAULT) - .setting("xpack.watcher.enabled", "false") - .setting("xpack.ml.enabled", "false") - .setting("xpack.security.enabled", "false") - .setting("xpack.security.transport.ssl.enabled", "false") - .setting("xpack.security.http.ssl.enabled", "false") + .distribution(DistributionType.INTEG_TEST) + .plugin("x-pack-analytics") + .module("aggregations") .jvmArg("-Xmx1g") .build();