|
45 | 45 | @WithoutSecurityManager |
46 | 46 | public class JvmOptionsParserTests extends ESTestCase { |
47 | 47 |
|
48 | | - private static final Map<String, String> TEST_SYSPROPS = Map.of("os.name", "Linux", "os.arch", "aarch64"); |
49 | | - |
50 | | - private static final Path ENTITLEMENTS_LIB_DIR = Path.of("lib", "entitlement-bridge"); |
| 48 | + private static Map<String, String> testSysprops; |
51 | 49 |
|
52 | 50 | @BeforeClass |
53 | 51 | public static void beforeClass() throws IOException { |
54 | | - Files.createDirectories(ENTITLEMENTS_LIB_DIR); |
55 | | - Files.createTempFile(ENTITLEMENTS_LIB_DIR, "mock-entitlements-bridge", ".jar"); |
| 52 | + Path homeDir = createTempDir(); |
| 53 | + Path entitlementLibDir = homeDir.resolve("lib/entitlement-bridge"); |
| 54 | + Files.createDirectories(entitlementLibDir); |
| 55 | + Files.createTempFile(entitlementLibDir, "mock-entitlements-bridge", ".jar"); |
| 56 | + testSysprops = Map.of("os.name", "Linux", "os.arch", "aarch64", "es.path.home", homeDir.toString()); |
56 | 57 | } |
57 | 58 |
|
58 | 59 | @AfterClass |
@@ -369,30 +370,30 @@ public void accept(final int lineNumber, final String line) { |
369 | 370 |
|
370 | 371 | public void testNodeProcessorsActiveCount() { |
371 | 372 | { |
372 | | - final List<String> jvmOptions = SystemJvmOptions.systemJvmOptions(Settings.EMPTY, TEST_SYSPROPS); |
| 373 | + final List<String> jvmOptions = SystemJvmOptions.systemJvmOptions(Settings.EMPTY, testSysprops); |
373 | 374 | assertThat(jvmOptions, not(hasItem(containsString("-XX:ActiveProcessorCount=")))); |
374 | 375 | } |
375 | 376 | { |
376 | 377 | Settings nodeSettings = Settings.builder().put(EsExecutors.NODE_PROCESSORS_SETTING.getKey(), 1).build(); |
377 | | - final List<String> jvmOptions = SystemJvmOptions.systemJvmOptions(nodeSettings, TEST_SYSPROPS); |
| 378 | + final List<String> jvmOptions = SystemJvmOptions.systemJvmOptions(nodeSettings, testSysprops); |
378 | 379 | assertThat(jvmOptions, hasItem("-XX:ActiveProcessorCount=1")); |
379 | 380 | } |
380 | 381 | { |
381 | 382 | // check rounding |
382 | 383 | Settings nodeSettings = Settings.builder().put(EsExecutors.NODE_PROCESSORS_SETTING.getKey(), 0.2).build(); |
383 | | - final List<String> jvmOptions = SystemJvmOptions.systemJvmOptions(nodeSettings, TEST_SYSPROPS); |
| 384 | + final List<String> jvmOptions = SystemJvmOptions.systemJvmOptions(nodeSettings, testSysprops); |
384 | 385 | assertThat(jvmOptions, hasItem("-XX:ActiveProcessorCount=1")); |
385 | 386 | } |
386 | 387 | { |
387 | 388 | // check validation |
388 | 389 | Settings nodeSettings = Settings.builder().put(EsExecutors.NODE_PROCESSORS_SETTING.getKey(), 10000).build(); |
389 | | - var e = expectThrows(IllegalArgumentException.class, () -> SystemJvmOptions.systemJvmOptions(nodeSettings, TEST_SYSPROPS)); |
| 390 | + var e = expectThrows(IllegalArgumentException.class, () -> SystemJvmOptions.systemJvmOptions(nodeSettings, testSysprops)); |
390 | 391 | assertThat(e.getMessage(), containsString("setting [node.processors] must be <=")); |
391 | 392 | } |
392 | 393 | } |
393 | 394 |
|
394 | 395 | public void testCommandLineDistributionType() { |
395 | | - var sysprops = new HashMap<>(TEST_SYSPROPS); |
| 396 | + var sysprops = new HashMap<>(testSysprops); |
396 | 397 | sysprops.put("es.distribution.type", "testdistro"); |
397 | 398 | final List<String> jvmOptions = SystemJvmOptions.systemJvmOptions(Settings.EMPTY, sysprops); |
398 | 399 | assertThat(jvmOptions, hasItem("-Des.distribution.type=testdistro")); |
|
0 commit comments