Skip to content

Commit

Permalink
Drop cgroups testing on plain Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
jerboaa committed Mar 7, 2024
1 parent fd2f242 commit 419bd1f
Showing 1 changed file with 4 additions and 33 deletions.
37 changes: 4 additions & 33 deletions test/hotspot/jtreg/containers/cgroup/PlainRead.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

/*
* @test PlainRead
* @bug 8261242
* @key cgroups
* @requires os.family == "linux"
* @requires vm.flagless
Expand All @@ -33,48 +34,18 @@
*/

import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.Platform;
import jdk.test.whitebox.WhiteBox;

public class PlainRead {

static public void match(OutputAnalyzer oa, String what, String value) {
oa.shouldMatch("^.*" + what + " *" + value + ".*$");
}

static public void noMatch(OutputAnalyzer oa, String what, String value) {
oa.shouldNotMatch("^.*" + what + " *" + value + ".*$");
}

static final String good_value = "(\\d+|-1|-2|Unlimited)";
static final String bad_value = "(failed)";

static final String[] variables = {"Memory Limit is:", "CPU Quota is:", "CPU Period is:", "active_processor_count:"};

static public void isContainer(OutputAnalyzer oa) {
for (String v: variables) {
match(oa, v, good_value);
}
for (String v: variables) {
noMatch(oa, v, bad_value);
}
}

static public void isNotContainer(OutputAnalyzer oa) {
oa.shouldMatch("^.*Can't open /proc/self/mountinfo.*$");
}

public static void main(String[] args) throws Exception {
WhiteBox wb = WhiteBox.getWhiteBox();
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:os+container=trace", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
pb.start();

if (wb.isContainerized()) {
System.out.println("Inside a cgroup, testing...");
isContainer(output);
} else {
System.out.println("Not containerized. Skipping...");
throw new RuntimeException("Test failed! Expected not containerized on plain Linux.");
}
System.out.println("Plain linux, no limits. Passed!");
}
}

0 comments on commit 419bd1f

Please sign in to comment.