Skip to content

Commit dbde218

Browse files
authored
allocation: fix up random long usage with inclusive bound (elastic#139163)
In the write load constraint monitor tests, the criteria for specifying a non-hotspot node generated a random queue latency between 0 and the hotspot threshold setting. In usage, the random number generation used the threshold as an inclusive bound, while it needed to be an exclusive bound. This became an issue recently, with the addition of tests that specify a certain number of hotspot nodes, and remove them individually throughout the test (testHotspotCountTurnsOff). Fixes: elastic#139161
1 parent 0a4ec40 commit dbde218

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,6 @@ tests:
503503
- class: org.elasticsearch.xpack.logsdb.RandomizedRollingUpgradeIT
504504
method: testIndexingStandardSource
505505
issue: https://github.com/elastic/elasticsearch/issues/139153
506-
- class: org.elasticsearch.cluster.routing.allocation.WriteLoadConstraintMonitorTests
507-
method: testHotspotCountTurnsOff
508-
issue: https://github.com/elastic/elasticsearch/issues/139161
509506

510507
# Examples:
511508
#

server/src/test/java/org/elasticsearch/cluster/routing/allocation/WriteLoadConstraintMonitorTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ private static ClusterInfo createClusterInfoWithHotSpots(
660660
long queueLatencyThresholdMillis,
661661
int highUtilizationThresholdPercent
662662
) {
663+
assert queueLatencyThresholdMillis > 0 : "queue latency threshold must be positive";
663664
final Set<String> hotspotNodesSet = new HashSet<>(hotspotNodes);
664665
final float maxRatioForUnderUtilised = (highUtilizationThresholdPercent - 1) / 100.0f;
665666
ClusterInfo clusterInfo = ClusterInfo.builder()
@@ -690,7 +691,7 @@ private static ClusterInfo createClusterInfoWithHotSpots(
690691
new NodeUsageStatsForThreadPools.ThreadPoolUsageStats(
691692
randomNonNegativeInt(),
692693
randomFloatBetween(0f, maxRatioForUnderUtilised, true),
693-
randomLongBetween(0, queueLatencyThresholdMillis)
694+
randomLongBetween(0, queueLatencyThresholdMillis - 1)
694695
)
695696
)
696697
);

0 commit comments

Comments
 (0)