Skip to content

Commit f1a4d1b

Browse files
committed
8372615: Many container tests fail when running rootless on cgroup v1
Reviewed-by: sgehwolf, dholmes
1 parent 9497706 commit f1a4d1b

27 files changed

+83
-125
lines changed

test/hotspot/jtreg/containers/docker/DockerBasicTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
2929
* @requires !vm.asan
3030
* @library /test/lib
3131
* @modules java.base/jdk.internal.misc
32+
* java.base/jdk.internal.platform
3233
* java.management
3334
* jdk.jartool/sun.tools.jar
3435
* @build HelloDocker
@@ -45,10 +46,7 @@ public class DockerBasicTest {
4546
private static final String imageNameAndTag = Common.imageName("basic");
4647

4748
public static void main(String[] args) throws Exception {
48-
if (!DockerTestUtils.canTestDocker()) {
49-
return;
50-
}
51-
49+
DockerTestUtils.checkCanTestDocker();
5250
DockerTestUtils.buildJdkContainerImage(imageNameAndTag);
5351

5452
try {

test/hotspot/jtreg/containers/docker/ShareTmpDir.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
3030
* @requires container.support
3131
* @requires !vm.asan
3232
* @library /test/lib
33+
* @modules java.base/jdk.internal.platform
3334
* @build WaitForFlagFile
3435
* @run driver ShareTmpDir
3536
*/
@@ -50,10 +51,7 @@ public class ShareTmpDir {
5051
private static final String imageName = Common.imageName("sharetmpdir");
5152

5253
public static void main(String[] args) throws Exception {
53-
if (!DockerTestUtils.canTestDocker()) {
54-
return;
55-
}
56-
54+
DockerTestUtils.checkCanTestDocker();
5755
DockerTestUtils.buildJdkContainerImage(imageName);
5856

5957
try {

test/hotspot/jtreg/containers/docker/TestCPUAwareness.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -48,9 +48,8 @@ public class TestCPUAwareness {
4848
private static final int availableCPUs = Runtime.getRuntime().availableProcessors();
4949

5050
public static void main(String[] args) throws Exception {
51-
if (!DockerTestUtils.canTestDocker()) {
52-
return;
53-
}
51+
DockerTestUtils.checkCanTestDocker();
52+
DockerTestUtils.checkCanUseResourceLimits();
5453

5554
System.out.println("Test Environment: detected availableCPUs = " + availableCPUs);
5655
DockerTestUtils.buildJdkContainerImage(imageName);

test/hotspot/jtreg/containers/docker/TestCPUSets.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
3131
* @requires (os.arch != "s390x")
3232
* @library /test/lib
3333
* @modules java.base/jdk.internal.misc
34+
* java.base/jdk.internal.platform
3435
* java.management
3536
* jdk.jartool/sun.tools.jar
3637
* @build AttemptOOM jdk.test.whitebox.WhiteBox PrintContainerInfo
@@ -52,11 +53,8 @@ public class TestCPUSets {
5253
private static final String imageName = Common.imageName("cpusets");
5354

5455
public static void main(String[] args) throws Exception {
55-
if (!DockerTestUtils.canTestDocker()) {
56-
return;
57-
}
58-
59-
56+
DockerTestUtils.checkCanTestDocker();
57+
DockerTestUtils.checkCanUseResourceLimits();
6058
Common.prepareWhiteBox();
6159
DockerTestUtils.buildJdkContainerImage(imageName);
6260

test/hotspot/jtreg/containers/docker/TestContainerInfo.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2024, Red Hat, Inc.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -31,6 +31,7 @@
3131
* @requires !vm.asan
3232
* @library /test/lib
3333
* @modules java.base/jdk.internal.misc
34+
* java.base/jdk.internal.platform
3435
* java.management
3536
* jdk.jartool/sun.tools.jar
3637
* @build CheckContainerized jdk.test.whitebox.WhiteBox PrintContainerInfo
@@ -49,10 +50,7 @@ public class TestContainerInfo {
4950
private static final String imageName = Common.imageName("container-info");
5051

5152
public static void main(String[] args) throws Exception {
52-
if (!DockerTestUtils.canTestDocker()) {
53-
return;
54-
}
55-
53+
DockerTestUtils.checkCanTestDocker();
5654
Common.prepareWhiteBox();
5755
DockerTestUtils.buildJdkContainerImage(imageName);
5856

test/hotspot/jtreg/containers/docker/TestJFREvents.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
* @modules java.base/jdk.internal.platform
3535
* @library /test/lib
3636
* @modules java.base/jdk.internal.misc
37+
* java.base/jdk.internal.platform
3738
* java.management
3839
* jdk.jartool/sun.tools.jar
3940
* @build JfrReporter jdk.test.whitebox.WhiteBox
@@ -61,9 +62,7 @@ public class TestJFREvents {
6162

6263
public static void main(String[] args) throws Exception {
6364
System.out.println("Test Environment: detected availableCPUs = " + availableCPUs);
64-
if (!DockerTestUtils.canTestDocker()) {
65-
return;
66-
}
65+
DockerTestUtils.checkCanTestDocker();
6766

6867
// If cgroups is not configured, report success.
6968
Metrics metrics = Metrics.systemMetrics();

test/hotspot/jtreg/containers/docker/TestJFRNetworkEvents.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
3131
* @requires !vm.asan
3232
* @library /test/lib
3333
* @modules java.base/jdk.internal.misc
34+
* java.base/jdk.internal.platform
3435
* java.management
3536
* jdk.jartool/sun.tools.jar
3637
* @build JfrNetwork
@@ -48,10 +49,7 @@ public class TestJFRNetworkEvents {
4849

4950
public static void main(String[] args) throws Exception {
5051
System.out.println("Test Environment: detected availableCPUs = " + availableCPUs);
51-
if (!DockerTestUtils.canTestDocker()) {
52-
return;
53-
}
54-
52+
DockerTestUtils.checkCanTestDocker();
5553
DockerTestUtils.buildJdkContainerImage(imageName);
5654

5755
try {

test/hotspot/jtreg/containers/docker/TestJFRWithJMX.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
2929
* @requires !vm.asan
3030
* @library /test/lib
3131
* @modules java.base/jdk.internal.misc
32+
* java.base/jdk.internal.platform
3233
* java.management
3334
* jdk.jartool/sun.tools.jar
3435
* @build EventProducer
@@ -73,9 +74,7 @@ public class TestJFRWithJMX {
7374
static final AtomicReference<String> ipAddr = new AtomicReference();
7475

7576
public static void main(String[] args) throws Exception {
76-
if (!DockerTestUtils.canTestDocker()) {
77-
throw new SkippedException("Docker is not supported on this host");
78-
}
77+
DockerTestUtils.checkCanTestDocker();
7978

8079
if (DockerTestUtils.isPodman() & !Platform.isRoot()) {
8180
throw new SkippedException("test cannot be run under rootless podman configuration");

test/hotspot/jtreg/containers/docker/TestJcmd.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* @requires container.support
3030
* @requires vm.flagless
3131
* @modules java.base/jdk.internal.misc
32+
* java.base/jdk.internal.platform
3233
* java.management
3334
* jdk.jartool/sun.tools.jar
3435
* @library /test/lib
@@ -62,7 +63,7 @@ public class TestJcmd {
6263

6364

6465
public static void main(String[] args) throws Exception {
65-
DockerTestUtils.canTestDocker();
66+
DockerTestUtils.checkCanTestDocker();
6667

6768
// podman versions below 3.3.1 hava a bug where cross-container testing with correct
6869
// permissions fails. See JDK-8273216

test/hotspot/jtreg/containers/docker/TestJcmdWithSideCar.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
3333
* @requires vm.flagless
3434
* @requires !vm.asan
3535
* @modules java.base/jdk.internal.misc
36+
* java.base/jdk.internal.platform
3637
* java.management
3738
* jdk.jartool/sun.tools.jar
3839
* @library /test/lib
@@ -95,10 +96,7 @@ public class TestJcmdWithSideCar {
9596
private static final String NET_BIND_SERVICE = "--cap-add=NET_BIND_SERVICE";
9697

9798
public static void main(String[] args) throws Exception {
98-
if (!DockerTestUtils.canTestDocker()) {
99-
return;
100-
}
101-
99+
DockerTestUtils.checkCanTestDocker();
102100
DockerTestUtils.buildJdkContainerImage(IMAGE_NAME);
103101

104102
try {

0 commit comments

Comments
 (0)