Skip to content
Permalink
Browse files
8264524: jdk/internal/platform/docker/TestDockerMemoryMetrics.java fa…
…ils due to swapping not working

Reviewed-by: sgehwolf
  • Loading branch information
DamonFool committed Apr 6, 2021
1 parent a756d8d commit bfb034abf9d5e5eb24d524f35b3f745e94631c4a
Showing with 25 additions and 2 deletions.
  1. +25 −2 test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java
@@ -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 @@ private static void testMemoryLimit(String value) throws Exception {

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 @@ private static void testMemoryFailCount(String value) throws Exception {
.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 {

1 comment on commit bfb034a

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on bfb034a Apr 6, 2021

Please sign in to comment.