mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-15 10:23:28 +00:00
8292206: TestCgroupMetrics.java fails as getMemoryUsage() is lower than expected
Reviewed-by: dholmes, sgehwolf
This commit is contained in:
parent
b378381a9c
commit
6ccee83958
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2022, 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
|
||||
@ -36,16 +36,7 @@ import jdk.internal.platform.Metrics;
|
||||
public class TestCgroupMetrics {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// If cgroups is not configured, report success.
|
||||
Metrics metrics = Metrics.systemMetrics();
|
||||
if (metrics == null) {
|
||||
System.out.println("TEST PASSED!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
MetricsTester metricsTester = new MetricsTester();
|
||||
metricsTester.testAll(metrics);
|
||||
System.out.println("TEST PASSED!!!");
|
||||
MetricsTester.main(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2022, 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
|
||||
@ -55,6 +55,7 @@ public class TestSystemMetrics {
|
||||
opts.addDockerOpts("--memory=256m");
|
||||
opts.addJavaOpts("-cp", "/test-classes/");
|
||||
opts.addJavaOpts("--add-exports", "java.base/jdk.internal.platform=ALL-UNNAMED");
|
||||
opts.addClassOptions("-incontainer");
|
||||
DockerTestUtils.dockerRunJava(opts).shouldHaveExitValue(0).shouldContain("TEST PASSED!!!");
|
||||
} finally {
|
||||
DockerTestUtils.removeDockerImage(imageName);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Red Hat Inc.
|
||||
* Copyright (c) 2020, 2022, Red Hat Inc.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -52,14 +52,22 @@ public class MetricsTester {
|
||||
}
|
||||
}
|
||||
|
||||
public void testAll(Metrics m) throws Exception {
|
||||
private void testAll(Metrics m, boolean inContainer) throws Exception {
|
||||
CgroupMetricsTester tester = createInstance(m);
|
||||
tester.testCpuAccounting();
|
||||
tester.testCpuConsumption();
|
||||
tester.testCpuSchedulingMetrics();
|
||||
tester.testCpuSets();
|
||||
tester.testMemorySubsystem();
|
||||
tester.testMemoryUsage();
|
||||
if (!inContainer) {
|
||||
// If not running in a container, these test cases query the memory usage.
|
||||
// of all processes in the entire system (or those belonging to the current
|
||||
// Linux user). They cannot produce predictable results due to interference
|
||||
// from unrelated processes.
|
||||
System.out.println("testMemorySubsystem and testMemoryUsage skipped");
|
||||
} else {
|
||||
tester.testMemorySubsystem();
|
||||
tester.testMemoryUsage();
|
||||
}
|
||||
tester.testMisc();
|
||||
}
|
||||
|
||||
@ -71,8 +79,14 @@ public class MetricsTester {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean inContainer = false;
|
||||
if (args.length > 0 && "-incontainer".equals(args[0])) {
|
||||
inContainer = true;
|
||||
}
|
||||
System.out.println("inContainer = " + inContainer);
|
||||
|
||||
MetricsTester metricsTester = new MetricsTester();
|
||||
metricsTester.testAll(m);
|
||||
metricsTester.testAll(m, inContainer);
|
||||
System.out.println("TEST PASSED!!!");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user