Skip to content

Commit

Permalink
8274506: TestPids.java and TestPidsLimit.java fail with podman run as…
Browse files Browse the repository at this point in the history
… root

Backport-of: 94e31e5ca51d1c4c253cf7ac5acd950d10c22267
  • Loading branch information
MBaesken committed Jun 27, 2022
1 parent 1fbbd15 commit d7b6f7f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion test/hotspot/jtreg/containers/docker/TestPids.java
Expand Up @@ -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";

Expand Down Expand Up @@ -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);
}
Expand Down
7 changes: 6 additions & 1 deletion test/jdk/jdk/internal/platform/docker/TestPidsLimit.java
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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);
}
Expand Down

1 comment on commit d7b6f7f

@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.