TEST BUG: MergeSchedulerSettingsTests fails always on small machines (#559)

MergeSchedulerSettingsTests tweaks the `node.processors` setting: sets it
explicitly to values of `2` and `8`. On a machine with only `4` threads
(e.g. my 2-core thinkpad), the test fails, because it creates unexpected
warnings about `node.processors` being set higher than the number of
cpus.

The problem can be reproduced always, by pretending to be single core:
```
./gradlew ':server:test' --tests "org.opensearch.index.MergeSchedulerSettingsTests.testMaxThreadAndMergeCount" -Dtests.jvm.argline="-XX:ActiveProcessorCount=1"
```

Instead, allow the test to provoke these specific warnings.

Signed-off-by: Robert Muir <rmuir@apache.org>
This commit is contained in:
Robert Muir 2021-04-15 14:57:57 -04:00 committed by GitHub
parent 6aa3675e9d
commit bdb7aade9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -192,5 +192,14 @@ public class MergeSchedulerSettingsTests extends OpenSearchTestCase {
exc = expectThrows(IllegalArgumentException.class,
() -> finalSettings.updateIndexMetadata(createMetadata(-1, 3, 8)));
assertThat(exc.getMessage(), containsString("maxThreadCount (= 4) should be <= maxMergeCount (= 3)"));
// assertions above may provoke warnings if node.processors exceeds numCpus
// we explicitly test with values of 2 and 8
int numCpus = Runtime.getRuntime().availableProcessors();
String[] warnings = new String[] {
"setting [node.processors] to value [2] which is more than available processors [" + numCpus + "] is deprecated",
"setting [node.processors] to value [8] which is more than available processors [" + numCpus + "] is deprecated"
};
allowedWarnings(warnings);
}
}