Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 bfb034a
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions 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
Expand Down Expand Up @@ -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/")
Expand All @@ -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 {
Expand Down

1 comment on commit bfb034a

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.