Skip to content

Commit 8ebe466

Browse files
committed
Fix failing scaling thread pool test
The previous commit took away the distinction between relying on the defaults versus relying on an explicit setting for processors. This commit adds this back, and adjusts the logic to account for the fact that processors can not exceed available processors any longer.
1 parent 5b2d1a5 commit 8ebe466

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

server/src/test/java/org/elasticsearch/threadpool/ScalingThreadPoolTests.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,17 @@ public void testScalingThreadPoolConfiguration() throws InterruptedException {
4848
core = "generic".equals(threadPoolName) ? 4 : 1; // the defaults
4949
}
5050

51-
final int processors = randomIntBetween(1, Runtime.getRuntime().availableProcessors());
52-
final int maxBasedOnNumberOfProcessors = expectedSize(threadPoolName, processors);
51+
final int availableProcessors = Runtime.getRuntime().availableProcessors();
52+
final int maxBasedOnNumberOfProcessors;
53+
final int processors;
54+
if (randomBoolean()) {
55+
processors = randomIntBetween(1, availableProcessors);
56+
maxBasedOnNumberOfProcessors = expectedSize(threadPoolName, processors);
57+
builder.put("processors", processors);
58+
} else {
59+
maxBasedOnNumberOfProcessors = expectedSize(threadPoolName, availableProcessors);
60+
processors = availableProcessors;
61+
}
5362

5463
final int expectedMax;
5564
if (maxBasedOnNumberOfProcessors < core || randomBoolean()) {

0 commit comments

Comments
 (0)