Fix Test Failure in ScalingThreadPoolTests (#44898) (#44901)

* Due to #44894 some constellations log a deprecation warning here now
* Fixed by checking for that
This commit is contained in:
Armin Braun 2019-07-26 17:05:50 +02:00 committed by GitHub
parent 79121ea127
commit 1340ff19bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -48,13 +48,17 @@ public class ScalingThreadPoolTests extends ESThreadPoolTestCase {
core = "generic".equals(threadPoolName) ? 4 : 1; // the defaults
}
final int availableProcessors = Runtime.getRuntime().availableProcessors();
final int maxBasedOnNumberOfProcessors;
final int processorsUsed;
if (randomBoolean()) {
final int processors = randomIntBetween(1, 64);
maxBasedOnNumberOfProcessors = expectedSize(threadPoolName, processors);
builder.put("processors", processors);
processorsUsed = processors;
} else {
maxBasedOnNumberOfProcessors = expectedSize(threadPoolName, Runtime.getRuntime().availableProcessors());
maxBasedOnNumberOfProcessors = expectedSize(threadPoolName, availableProcessors);
processorsUsed = availableProcessors;
}
final int expectedMax;
@ -93,6 +97,11 @@ public class ScalingThreadPoolTests extends ESThreadPoolTestCase {
assertThat(info.getMax(), equalTo(expectedMax));
assertThat(esThreadPoolExecutor.getMaximumPoolSize(), equalTo(expectedMax));
});
if (processorsUsed > availableProcessors) {
assertWarnings("setting processors to value [" + processorsUsed +
"] which is more than available processors [" + availableProcessors + "] is deprecated");
}
}
private int expectedSize(final String threadPoolName, final int numberOfProcessors) {