Skip to content

Commit

Permalink
[M]] Fix failing JobNodeSelectorTests (elastic#98541)
Browse files Browse the repository at this point in the history
Tests have started failing in 8.11 as they are missing an appropriate value for the ML_CONFIG_VERSION_NODE_ATTR node attribute
  • Loading branch information
edsavage authored Aug 17, 2023
1 parent de87554 commit af071cc
Showing 1 changed file with 52 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
)
)
Expand All @@ -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
)
Expand All @@ -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
)
Expand All @@ -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
)
Expand Down

0 comments on commit af071cc

Please sign in to comment.