mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-12 22:50:08 +00:00
8264524: jdk/internal/platform/docker/TestDockerMemoryMetrics.java fails due to swapping not working
Reviewed-by: sgehwolf
This commit is contained in:
parent
a756d8d7ef
commit
bfb034abf9
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -102,6 +102,23 @@ public class TestDockerMemoryMetrics {
|
||||
|
||||
private static void testMemoryFailCount(String value) throws Exception {
|
||||
Common.logNewTestCase("testMemoryFailCount" + value);
|
||||
|
||||
// Check whether swapping really works for this test
|
||||
// On some systems there is no swap space enabled. And running
|
||||
// 'java -Xms{mem-limit} -Xmx{mem-limit} -version' would fail due to swap space size being 0.
|
||||
DockerRunOptions preOpts =
|
||||
new DockerRunOptions(imageName, "/jdk/bin/java", "-version");
|
||||
preOpts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/")
|
||||
.addDockerOpts("--memory=" + value)
|
||||
.addJavaOpts("-Xms" + value)
|
||||
.addJavaOpts("-Xmx" + value);
|
||||
OutputAnalyzer oa = DockerTestUtils.dockerRunJava(preOpts);
|
||||
String output = oa.getOutput();
|
||||
if (!output.contains("version")) {
|
||||
System.out.println("Swapping doesn't work for this test.");
|
||||
return;
|
||||
}
|
||||
|
||||
DockerRunOptions opts =
|
||||
new DockerRunOptions(imageName, "/jdk/bin/java", "MetricsMemoryTester");
|
||||
opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/")
|
||||
@ -110,7 +127,13 @@ public class TestDockerMemoryMetrics {
|
||||
.addJavaOpts("-cp", "/test-classes/")
|
||||
.addJavaOpts("--add-exports", "java.base/jdk.internal.platform=ALL-UNNAMED")
|
||||
.addClassOptions("failcount");
|
||||
DockerTestUtils.dockerRunJava(opts).shouldHaveExitValue(0).shouldContain("TEST PASSED!!!");
|
||||
oa = DockerTestUtils.dockerRunJava(opts);
|
||||
output = oa.getOutput();
|
||||
if (output.contains("Ignoring test")) {
|
||||
System.out.println("Ignored by the tester");
|
||||
return;
|
||||
}
|
||||
oa.shouldHaveExitValue(0).shouldContain("TEST PASSED!!!");
|
||||
}
|
||||
|
||||
private static void testMemoryAndSwapLimit(String memory, String memandswap) throws Exception {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user