From 198c30bc120f8899e7ef3ee7778ff673f45f9055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20J=C3=B3zala?= <377355+jozala@users.noreply.github.com> Date: Wed, 20 Aug 2025 13:29:54 +0200 Subject: [PATCH 1/2] Set default processor allocation for test clusters (#133204) Setting the number of processors available for node to adequately size thread pools. Related to #130612 --- .../gradle/internal/InternalTestClustersPlugin.java | 13 +++++++------ .../test/cluster/local/DefaultSettingsProvider.java | 4 ++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalTestClustersPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalTestClustersPlugin.java index f1b96016286df..2a2e1ea28d1ec 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalTestClustersPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalTestClustersPlugin.java @@ -34,12 +34,13 @@ public void apply(Project project) { || buildParams.getBwcVersions().unreleasedInfo(version) == null ); - if (shouldConfigureTestClustersWithOneProcessor()) { - NamedDomainObjectContainer testClusters = (NamedDomainObjectContainer) project - .getExtensions() - .getByName(TestClustersPlugin.EXTENSION_NAME); - testClusters.configureEach(elasticsearchCluster -> elasticsearchCluster.setting("node.processors", "1")); - } + NamedDomainObjectContainer testClusters = (NamedDomainObjectContainer) project + .getExtensions() + .getByName(TestClustersPlugin.EXTENSION_NAME); + // Limit the number of allocated processors for all nodes to 2 in the cluster by default. + // This is to ensure that the tests run consistently across different environments. + String processorCount = shouldConfigureTestClustersWithOneProcessor() ? "1" : "2"; + testClusters.configureEach(elasticsearchCluster -> elasticsearchCluster.setting("node.processors", processorCount)); } private boolean shouldConfigureTestClustersWithOneProcessor() { diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java index b53f4ece46134..2fdf0df41736a 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java @@ -42,6 +42,10 @@ public Map get(LocalNodeSpec nodeSpec) { } } + // Limit the number of allocated processors for all nodes in the cluster by default. + // This is to ensure that the tests run consistently across different environments. + settings.put("node.processors", "2"); + // Default the watermarks to absurdly low to prevent the tests from failing on nodes without enough disk space settings.put("cluster.routing.allocation.disk.watermark.low", "1b"); settings.put("cluster.routing.allocation.disk.watermark.high", "1b"); From 3868e3f65f8d5a3d6b990ec9692eaa8bb8bd1d9a Mon Sep 17 00:00:00 2001 From: Jonathan Buttner Date: Fri, 22 Aug 2025 14:32:05 -0400 Subject: [PATCH 2/2] Lowering the allocations during update to fit within available processors --- .../elasticsearch/xpack/inference/CreateFromDeploymentIT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/CreateFromDeploymentIT.java b/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/CreateFromDeploymentIT.java index 96cc528073635..4039ea6f55b0b 100644 --- a/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/CreateFromDeploymentIT.java +++ b/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/CreateFromDeploymentIT.java @@ -51,7 +51,7 @@ public void testAttachToDeployment() throws IOException { var results = infer(inferenceId, List.of("washing machine")); assertNotNull(results.get("sparse_embedding")); - var updatedNumAllocations = randomIntBetween(1, 10); + var updatedNumAllocations = randomIntBetween(1, 2); var updatedEndpointConfig = updateEndpoint(inferenceId, updatedEndpointConfig(updatedNumAllocations), TaskType.SPARSE_EMBEDDING); assertThat( updatedEndpointConfig.get("service_settings"), @@ -128,7 +128,7 @@ public void testAttachWithModelId() throws IOException { var results = infer(inferenceId, List.of("washing machine")); assertNotNull(results.get("sparse_embedding")); - var updatedNumAllocations = randomIntBetween(1, 10); + var updatedNumAllocations = randomIntBetween(1, 2); var updatedEndpointConfig = updateEndpoint(inferenceId, updatedEndpointConfig(updatedNumAllocations), TaskType.SPARSE_EMBEDDING); assertThat( updatedEndpointConfig.get("service_settings"),