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"); 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"),