Skip to content

Commit a828c24

Browse files
committed
8369441: Two container tests fail after JDK-8292984
1 parent 2c114d6 commit a828c24

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

test/hotspot/jtreg/containers/docker/TestJFREvents.java

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,28 @@
3636
* @modules java.base/jdk.internal.misc
3737
* java.management
3838
* jdk.jartool/sun.tools.jar
39-
* @build JfrReporter
40-
* @run driver TestJFREvents
39+
* @build JfrReporter jdk.test.whitebox.WhiteBox
40+
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox
41+
* @run main/othervm -Xbootclasspath/a:whitebox.jar -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestJFREvents
4142
*/
4243
import java.util.List;
44+
import jdk.internal.platform.Metrics;
4345
import jdk.test.lib.containers.docker.Common;
4446
import jdk.test.lib.containers.docker.DockerRunOptions;
4547
import jdk.test.lib.containers.docker.DockerTestUtils;
4648
import jdk.test.lib.Asserts;
4749
import jdk.test.lib.process.OutputAnalyzer;
4850
import jdk.test.lib.Utils;
49-
import jdk.internal.platform.Metrics;
51+
import jdk.test.whitebox.WhiteBox;
5052

5153

5254
public class TestJFREvents {
5355
private static final String imageName = Common.imageName("jfr-events");
5456
private static final String TEST_ENV_VARIABLE = "UNIQUE_VARIABLE_ABC592903XYZ";
5557
private static final String TEST_ENV_VALUE = "unique_value_abc592903xyz";
5658
private static final int availableCPUs = Runtime.getRuntime().availableProcessors();
57-
private static final int UNKNOWN = -100;
5859
private static boolean isCgroupV1 = false;
60+
private static final WhiteBox wb = WhiteBox.getWhiteBox();
5961

6062
public static void main(String[] args) throws Exception {
6163
System.out.println("Test Environment: detected availableCPUs = " + availableCPUs);
@@ -99,7 +101,7 @@ public static void main(String[] args) throws Exception {
99101
}
100102

101103
private static void containerInfoTestCase() throws Exception {
102-
long hostTotalMemory = getHostTotalMemory();
104+
long hostTotalMemory = wb.hostPhysicalMemory();
103105
System.out.println("Debug: Host total memory is " + hostTotalMemory);
104106
// Leave one CPU for system and tools, otherwise this test may be unstable.
105107
// Try the memory sizes that were verified by testMemory tests before.
@@ -111,18 +113,6 @@ private static void containerInfoTestCase() throws Exception {
111113
}
112114
}
113115

114-
private static long getHostTotalMemory() throws Exception {
115-
DockerRunOptions opts = Common.newOpts(imageName);
116-
117-
String hostMem = Common.run(opts).firstMatch("total physical memory: (\\d+)", 1);
118-
try {
119-
return Long.parseLong(hostMem);
120-
} catch (NumberFormatException e) {
121-
System.out.println("Could not parse total physical memory '" + hostMem + "' returning " + UNKNOWN);
122-
return UNKNOWN;
123-
}
124-
}
125-
126116
private static void testContainerInfo(int expectedCPUs, int expectedMemoryMB, long hostTotalMemory) throws Exception {
127117
Common.logNewTestCase("ContainerInfo: --cpus=" + expectedCPUs + " --memory=" + expectedMemoryMB + "m");
128118
String eventName = "jdk.ContainerConfiguration";

test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private static void testContainerMemExceedsPhysical()
140140
.addDockerOpts("--memory", badMem);
141141

142142
Common.run(opts)
143-
.shouldMatch("container memory limit (ignored: " + badMem + "|unlimited: -1), using host value " + hostMaxMem);
143+
.shouldMatch("container memory limit (ignored: " + badMem + "|unlimited: -1), upper bound is " + hostMaxMem);
144144
}
145145

146146

0 commit comments

Comments
 (0)