From af071ccc314a0975a9b6e1b6ce7d2a9f92d75a09 Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Thu, 17 Aug 2023 14:06:05 +0100 Subject: [PATCH] [M]] Fix failing JobNodeSelectorTests (#98541) Tests have started failing in 8.11 as they are missing an appropriate value for the ML_CONFIG_VERSION_NODE_ATTR node attribute --- .../xpack/ml/job/JobNodeSelectorTests.java | 72 +++++++++++++------ 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/JobNodeSelectorTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/JobNodeSelectorTests.java index 32a684097d601..19546b37c00cd 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/JobNodeSelectorTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/JobNodeSelectorTests.java @@ -6,7 +6,6 @@ */ package org.elasticsearch.xpack.ml.job; -import org.apache.lucene.tests.util.LuceneTestCase; import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -59,7 +58,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/98552") public class JobNodeSelectorTests extends ESTestCase { // To simplify the logic in this class all jobs have the same memory requirement @@ -116,7 +114,9 @@ public void testSelectLeastLoadedMlNodeForAnomalyDetectorJob_maxCapacityCountLim MachineLearning.MACHINE_MEMORY_NODE_ATTR, Long.toString(machineMemory), MachineLearning.MAX_JVM_SIZE_NODE_ATTR, - Long.toString(machineMemory / 2) + Long.toString(machineMemory / 2), + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ); ClusterState.Builder cs = fillNodesWithRunningJobs(nodeAttr, numNodes, maxRunningJobsPerNode); @@ -162,7 +162,9 @@ public void testSelectLeastLoadedMlNodeForDataFrameAnalyticsJob_maxCapacityCount MachineLearning.MACHINE_MEMORY_NODE_ATTR, Long.toString(machineMemory), MachineLearning.MAX_JVM_SIZE_NODE_ATTR, - Long.toString(machineMemory / 2) + Long.toString(machineMemory / 2), + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ); ClusterState.Builder cs = fillNodesWithRunningJobs(nodeAttr, numNodes, maxRunningJobsPerNode); @@ -214,7 +216,9 @@ public void testSelectLeastLoadedMlNodeForAnomalyDetectorJob_maxCapacityMemoryLi MachineLearning.MACHINE_MEMORY_NODE_ATTR, Long.toString(machineMemory), MachineLearning.MAX_JVM_SIZE_NODE_ATTR, - Long.toString(machineMemory / 2) + Long.toString(machineMemory / 2), + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ); ClusterState.Builder cs = fillNodesWithRunningJobs(nodeAttr, numNodes, currentlyRunningJobsPerNode); @@ -268,7 +272,9 @@ public void testSelectLeastLoadedMlNodeForDataFrameAnalyticsJob_givenTaskHasNull MachineLearning.MACHINE_MEMORY_NODE_ATTR, String.valueOf(ByteSizeValue.ofGb(1).getBytes()), MachineLearning.MAX_JVM_SIZE_NODE_ATTR, - String.valueOf(ByteSizeValue.ofMb(400).getBytes()) + String.valueOf(ByteSizeValue.ofMb(400).getBytes()), + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ); ClusterState.Builder cs = fillNodesWithRunningJobs(nodeAttr, numNodes, 1, JobState.OPENED, null); @@ -305,7 +311,9 @@ public void testSelectLeastLoadedMlNodeForAnomalyDetectorJob_firstJobTooBigMemor MachineLearning.MACHINE_MEMORY_NODE_ATTR, Long.toString(machineMemory), MachineLearning.MAX_JVM_SIZE_NODE_ATTR, - Long.toString(machineMemory / 2) + Long.toString(machineMemory / 2), + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ); ClusterState.Builder cs = fillNodesWithRunningJobs(nodeAttr, numNodes, 0); @@ -362,7 +370,9 @@ public void testSelectLeastLoadedMlNodeForDataFrameAnalyticsJob_maxCapacityMemor MachineLearning.MACHINE_MEMORY_NODE_ATTR, Long.toString(machineMemory), MachineLearning.MAX_JVM_SIZE_NODE_ATTR, - Long.toString(machineMemory / 2) + Long.toString(machineMemory / 2), + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ); ClusterState.Builder cs = fillNodesWithRunningJobs(nodeAttr, numNodes, currentlyRunningJobsPerNode); @@ -418,7 +428,9 @@ public void testSelectLeastLoadedMlNodeForDataFrameAnalyticsJob_firstJobTooBigMe MachineLearning.MACHINE_MEMORY_NODE_ATTR, Long.toString(machineMemory), MachineLearning.MAX_JVM_SIZE_NODE_ATTR, - Long.toString(machineMemory / 2) + Long.toString(machineMemory / 2), + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ); ClusterState.Builder cs = fillNodesWithRunningJobs(nodeAttr, numNodes, 0); @@ -512,7 +524,9 @@ public void testSelectLeastLoadedMlNode_maxConcurrentOpeningJobs() { MachineLearning.MACHINE_MEMORY_NODE_ATTR, "1000000000", MachineLearning.MAX_JVM_SIZE_NODE_ATTR, - "400000000" + "400000000", + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ); DiscoveryNodes nodes = DiscoveryNodes.builder() .add( @@ -644,7 +658,9 @@ public void testSelectLeastLoadedMlNode_concurrentOpeningJobsAndStaleFailedJob() MachineLearning.MACHINE_MEMORY_NODE_ATTR, "1000000000", MachineLearning.MAX_JVM_SIZE_NODE_ATTR, - "400000000" + "400000000", + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ); DiscoveryNodes nodes = DiscoveryNodes.builder() .add( @@ -739,7 +755,9 @@ public void testSelectLeastLoadedMlNode_noCompatibleJobTypeNodes() { MachineLearning.MACHINE_MEMORY_NODE_ATTR, "1000000000", MachineLearning.MAX_JVM_SIZE_NODE_ATTR, - "400000000" + "400000000", + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ); DiscoveryNodes nodes = DiscoveryNodes.builder() .add( @@ -797,7 +815,9 @@ public void testSelectLeastLoadedMlNode_reasonsAreInDeterministicOrder() { MachineLearning.MACHINE_MEMORY_NODE_ATTR, "1000000000", MachineLearning.MAX_JVM_SIZE_NODE_ATTR, - "400000000" + "400000000", + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ); DiscoveryNodes nodes = DiscoveryNodes.builder() .add( @@ -935,7 +955,9 @@ public void testSelectLeastLoadedMlNode_jobWithRules() { MachineLearning.MACHINE_MEMORY_NODE_ATTR, "1000000000", MachineLearning.MAX_JVM_SIZE_NODE_ATTR, - "400000000" + "400000000", + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ); DiscoveryNodes nodes = DiscoveryNodes.builder() .add( @@ -989,7 +1011,9 @@ public void testSelectMlNodeOnlyOutOfCandidates() { MachineLearning.MACHINE_MEMORY_NODE_ATTR, "1000000000", MachineLearning.MAX_JVM_SIZE_NODE_ATTR, - "400000000" + "400000000", + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ); DiscoveryNodes nodes = DiscoveryNodes.builder() .add( @@ -1188,7 +1212,9 @@ public void testMaximumPossibleNodeMemoryTooSmall() { MachineLearning.MACHINE_MEMORY_NODE_ATTR, Long.toString(machineMemory), MachineLearning.MAX_JVM_SIZE_NODE_ATTR, - Long.toString(machineMemory / 2) + Long.toString(machineMemory / 2), + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ); ClusterState.Builder cs = fillNodesWithRunningJobs(nodeAttr, numNodes, maxRunningJobsPerNode); @@ -1229,7 +1255,7 @@ public void testPerceivedCapacityAndMaxFreeMemory() { "not_ml_node_name", "_node_id", new TransportAddress(InetAddress.getLoopbackAddress(), 9300), - Collections.emptyMap(), + Map.of(MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, MlConfigVersion.CURRENT.toString()), ROLES_WITHOUT_ML ) ) @@ -1242,7 +1268,9 @@ public void testPerceivedCapacityAndMaxFreeMemory() { MachineLearning.MAX_JVM_SIZE_NODE_ATTR, "10", MachineLearning.MACHINE_MEMORY_NODE_ATTR, - Long.toString(ByteSizeValue.ofGb(30).getBytes()) + Long.toString(ByteSizeValue.ofGb(30).getBytes()), + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ), ROLES_WITH_ML ) @@ -1256,7 +1284,9 @@ public void testPerceivedCapacityAndMaxFreeMemory() { MachineLearning.MAX_JVM_SIZE_NODE_ATTR, "10", MachineLearning.MACHINE_MEMORY_NODE_ATTR, - Long.toString(ByteSizeValue.ofGb(30).getBytes()) + Long.toString(ByteSizeValue.ofGb(30).getBytes()), + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ), ROLES_WITH_ML ) @@ -1270,7 +1300,9 @@ public void testPerceivedCapacityAndMaxFreeMemory() { MachineLearning.MAX_JVM_SIZE_NODE_ATTR, "10", MachineLearning.MACHINE_MEMORY_NODE_ATTR, - Long.toString(ByteSizeValue.ofGb(10).getBytes()) + Long.toString(ByteSizeValue.ofGb(10).getBytes()), + MlConfigVersion.ML_CONFIG_VERSION_NODE_ATTR, + MlConfigVersion.CURRENT.toString() ), ROLES_WITH_ML )