-
Notifications
You must be signed in to change notification settings - Fork 722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude OperatingSystemMXBean PhysicalMemory test in Docker #12420
Conversation
I'll add plinux. |
Even better would be to detect the VM is running in docker, not sure how to do that. |
test/functional/JLM_Tests/src/org/openj9/test/management/TestOperatingSystemMXBean.java
Outdated
Show resolved
Hide resolved
9c2f4ff
to
18501cb
Compare
Updated to detect when running in a Docker container on Linux rather than checking for hard coded platforms. Tested via grinders, which don't detect a container as expected on the OpenJ9 machines. Added an enum in the code, run one more grinder to validate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested this in other container environments (e.g. podman
)?
try (FileInputStream env = new FileInputStream("/.dockerenv")) { | ||
logger.info("/.dockerenv found"); | ||
inContainer = ContainerStatus.FOUND; | ||
return true; | ||
} catch (IOException e) { | ||
// no "/.dockerenv" file, fall through | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified to if (new File("/.dockerenv").exists()) { ...}
.
String line; | ||
while ((line = reader.readLine()) != null) { | ||
if (line.contains("docker")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested simplification:
if (reader.lines().anyMatch(line -> line.contains("docker"))) {
logger.info("Container found: " + line);
inContainer = ContainerStatus.FOUND;
return true;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't work because line
is used afterwards to log how the container was found, for easier debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that aspect. It could probably be reworked, but perhaps it's not worth it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated it to use your pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lambda need not change if you use findFirst()
:
Optional<String> docker = reader.lines().filter(line -> line.contains("docker")).findFirst();
if (docker.isPresent()) {
logger.info("Container found: " + docker.get());
inContainer = ContainerStatus.FOUND;
return true;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
test/functional/JLM_Tests/src/org/openj9/test/management/TestOperatingSystemMXBean.java
Show resolved
Hide resolved
be3f2e1
to
2fbbaad
Compare
Updated to address comments. New grinder https://ci.eclipse.org/openj9/view/Test/job/Grinder/1682 - passed. |
09b1718
to
59067d5
Compare
@pshipton just tried fix out at Adopt, and works greate on xLinux, pLinux and aarch64 docker nodes: It would be useful to have this in the release branch if possible for next week so we avoid unnecessary test triage noise... |
2030679
to
ca1f687
Compare
Part of tests testOSMXBeanLocal and testOSMXBeanRemote, which run org.openj9.test.management.TestOperatingSystemMXBean.runTestOSMXBean() Issue eclipse-openj9#12038 Signed-off-by: Peter Shipton <Peter_Shipton@ca.ibm.com>
New grinder https://ci.eclipse.org/openj9/view/Test/job/Grinder/1686 - passed. |
Part of tests testOSMXBeanLocal and testOSMXBeanRemote, which run
org.openj9.test.management.TestOperatingSystemMXBean.runTestOSMXBean()
Issue #12038