From 94e31e5ca51d1c4c253cf7ac5acd950d10c22267 Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Thu, 30 Sep 2021 08:53:31 +0000 Subject: [PATCH] 8274506: TestPids.java and TestPidsLimit.java fail with podman run as root Reviewed-by: mbaesken, cjplummer --- test/hotspot/jtreg/containers/docker/TestPids.java | 7 ++++++- test/jdk/jdk/internal/platform/docker/TestPidsLimit.java | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/containers/docker/TestPids.java b/test/hotspot/jtreg/containers/docker/TestPids.java index 5c1993b8a5ed7..5ae0f4a9f61e8 100644 --- a/test/hotspot/jtreg/containers/docker/TestPids.java +++ b/test/hotspot/jtreg/containers/docker/TestPids.java @@ -40,11 +40,15 @@ import jdk.test.lib.containers.docker.DockerRunOptions; import jdk.test.lib.containers.docker.DockerTestUtils; import jdk.test.lib.Asserts; +import jdk.test.lib.Container; import jdk.test.lib.Platform; import jdk.test.lib.Utils; public class TestPids { private static final String imageName = Common.imageName("pids"); + private static final boolean IS_PODMAN = Container.ENGINE_COMMAND.contains("podman"); + private static final int UNLIMITED_PIDS_PODMAN = 0; + private static final int UNLIMITED_PIDS_DOCKER = -1; static final String warning_kernel_no_pids_support = "WARNING: Your kernel does not support pids limit capabilities"; @@ -139,7 +143,8 @@ private static void testPids(String value) throws Exception { DockerRunOptions opts = commonOpts(); if (value.equals("Unlimited")) { - opts.addDockerOpts("--pids-limit=-1"); + int unlimited = IS_PODMAN ? UNLIMITED_PIDS_PODMAN : UNLIMITED_PIDS_DOCKER; + opts.addDockerOpts("--pids-limit=" + unlimited); } else { opts.addDockerOpts("--pids-limit="+value); } diff --git a/test/jdk/jdk/internal/platform/docker/TestPidsLimit.java b/test/jdk/jdk/internal/platform/docker/TestPidsLimit.java index 99ef9d0cf8c52..6c6ff76fa9998 100644 --- a/test/jdk/jdk/internal/platform/docker/TestPidsLimit.java +++ b/test/jdk/jdk/internal/platform/docker/TestPidsLimit.java @@ -39,9 +39,13 @@ import jdk.test.lib.containers.docker.DockerTestUtils; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.Asserts; +import jdk.test.lib.Container; public class TestPidsLimit { private static final String imageName = Common.imageName("pids"); + private static final boolean IS_PODMAN = Container.ENGINE_COMMAND.contains("podman"); + private static final int UNLIMITED_PIDS_PODMAN = 0; + private static final int UNLIMITED_PIDS_DOCKER = -1; public static void main(String[] args) throws Exception { if (!DockerTestUtils.canTestDocker()) { @@ -107,7 +111,8 @@ private static void testPidsLimit(String pidsLimit) throws Exception { Common.logNewTestCase("testPidsLimit (limit: " + pidsLimit + ")"); DockerRunOptions opts = Common.newOptsShowSettings(imageName); if (pidsLimit.equals("Unlimited")) { - opts.addDockerOpts("--pids-limit=-1"); + int unlimited = IS_PODMAN ? UNLIMITED_PIDS_PODMAN : UNLIMITED_PIDS_DOCKER; + opts.addDockerOpts("--pids-limit=" + unlimited); } else { opts.addDockerOpts("--pids-limit="+pidsLimit); }