8340092: [Linux] containers/systemd/SystemdMemoryAwarenessTest.java failing on some systems
Reviewed-by: mbaesken
This commit is contained in:
parent
5cffddc689
commit
64275e6bbf
24
test/hotspot/jtreg/containers/systemd/TEST.properties
Normal file
24
test/hotspot/jtreg/containers/systemd/TEST.properties
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2024, 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
|
||||||
|
# under the terms of the GNU General Public License version 2 only, as
|
||||||
|
# published by the Free Software Foundation.
|
||||||
|
#
|
||||||
|
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
# version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
# accompanied this code).
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License version
|
||||||
|
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
#
|
||||||
|
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
# or visit www.oracle.com if you need additional information or have any
|
||||||
|
# questions.
|
||||||
|
#
|
||||||
|
|
||||||
|
exclusiveAccess.dirs=.
|
@ -28,6 +28,7 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.NoSuchFileException;
|
import java.nio.file.NoSuchFileException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.StandardOpenOption;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -92,19 +93,23 @@ public class SystemdTestUtils {
|
|||||||
try {
|
try {
|
||||||
return SystemdTestUtils.systemdRunJava(opts);
|
return SystemdTestUtils.systemdRunJava(opts);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
cleanupFiles(files);
|
||||||
if (files.memory() != null) {
|
}
|
||||||
Files.delete(files.memory());
|
}
|
||||||
}
|
|
||||||
if (files.cpu() != null) {
|
private static void cleanupFiles(ResultFiles files) throws IOException {
|
||||||
Files.delete(files.cpu());
|
try {
|
||||||
}
|
if (files.memory() != null) {
|
||||||
if (files.sliceDotDDir() != null) {
|
Files.delete(files.memory());
|
||||||
FileUtils.deleteFileTreeUnchecked(files.sliceDotDDir());
|
|
||||||
}
|
|
||||||
} catch (NoSuchFileException e) {
|
|
||||||
// ignore
|
|
||||||
}
|
}
|
||||||
|
if (files.cpu() != null) {
|
||||||
|
Files.delete(files.cpu());
|
||||||
|
}
|
||||||
|
if (files.sliceDotDDir() != null) {
|
||||||
|
FileUtils.deleteFileTreeUnchecked(files.sliceDotDDir());
|
||||||
|
}
|
||||||
|
} catch (NoSuchFileException e) {
|
||||||
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,15 +140,23 @@ public class SystemdTestUtils {
|
|||||||
if (runOpts.hasSliceDLimit()) {
|
if (runOpts.hasSliceDLimit()) {
|
||||||
String dirName = String.format("%s.slice.d", SLICE_NAMESPACE_PREFIX);
|
String dirName = String.format("%s.slice.d", SLICE_NAMESPACE_PREFIX);
|
||||||
sliceDotDDir = SYSTEMD_CONFIG_HOME.resolve(Path.of(dirName));
|
sliceDotDDir = SYSTEMD_CONFIG_HOME.resolve(Path.of(dirName));
|
||||||
Files.createDirectory(sliceDotDDir);
|
// Using createDirectories since we only need to ensure the directory
|
||||||
|
// exists. Ignore it if already existent.
|
||||||
|
Files.createDirectories(sliceDotDDir);
|
||||||
|
|
||||||
if (runOpts.sliceDMemoryLimit != null) {
|
if (runOpts.sliceDMemoryLimit != null) {
|
||||||
Path memoryConfig = sliceDotDDir.resolve(Path.of(SLICE_D_MEM_CONFIG_FILE));
|
Path memoryConfig = sliceDotDDir.resolve(Path.of(SLICE_D_MEM_CONFIG_FILE));
|
||||||
Files.writeString(memoryConfig, getMemoryDSliceContent(runOpts));
|
Files.writeString(memoryConfig,
|
||||||
|
getMemoryDSliceContent(runOpts),
|
||||||
|
StandardOpenOption.TRUNCATE_EXISTING,
|
||||||
|
StandardOpenOption.CREATE);
|
||||||
}
|
}
|
||||||
if (runOpts.sliceDCpuLimit != null) {
|
if (runOpts.sliceDCpuLimit != null) {
|
||||||
Path cpuConfig = sliceDotDDir.resolve(Path.of(SLICE_D_CPU_CONFIG_FILE));
|
Path cpuConfig = sliceDotDDir.resolve(Path.of(SLICE_D_CPU_CONFIG_FILE));
|
||||||
Files.writeString(cpuConfig, getCPUDSliceContent(runOpts));
|
Files.writeString(cpuConfig,
|
||||||
|
getCPUDSliceContent(runOpts),
|
||||||
|
StandardOpenOption.TRUNCATE_EXISTING,
|
||||||
|
StandardOpenOption.CREATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +172,7 @@ public class SystemdTestUtils {
|
|||||||
throw new AssertionError("Failed to write systemd slice files");
|
throw new AssertionError("Failed to write systemd slice files");
|
||||||
}
|
}
|
||||||
|
|
||||||
systemdDaemonReload(cpu);
|
systemdDaemonReload(cpu, memory, sliceDotDDir);
|
||||||
|
|
||||||
return new ResultFiles(memory, cpu, sliceDotDDir);
|
return new ResultFiles(memory, cpu, sliceDotDDir);
|
||||||
}
|
}
|
||||||
@ -175,12 +188,25 @@ public class SystemdTestUtils {
|
|||||||
return String.format("%s-cpu", slice);
|
return String.format("%s-cpu", slice);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void systemdDaemonReload(Path cpu) throws Exception {
|
private static void systemdDaemonReload(Path cpu, Path memory, Path sliceDdir) throws Exception {
|
||||||
List<String> daemonReload = systemCtl();
|
List<String> daemonReload = systemCtl();
|
||||||
daemonReload.add("daemon-reload");
|
daemonReload.add("daemon-reload");
|
||||||
|
|
||||||
if (execute(daemonReload).getExitValue() != 0) {
|
if (execute(daemonReload).getExitValue() != 0) {
|
||||||
throw new AssertionError("Failed to reload systemd daemon");
|
if (RUN_AS_USER) {
|
||||||
|
cleanupFiles(new ResultFiles(cpu, memory, sliceDdir));
|
||||||
|
// When run as user the systemd user manager needs to be
|
||||||
|
// accessible and working. This is usually the case when
|
||||||
|
// connected via SSH or user login, but may not work for
|
||||||
|
// sessions set up via 'su <user>' or similar.
|
||||||
|
// In that case, 'systemctl --user status' usually doesn't
|
||||||
|
// work. There is no other option than skip the test.
|
||||||
|
String msg = "Service user@.service not properly configured. " +
|
||||||
|
"Skipping the test!";
|
||||||
|
throw new SkippedException(msg);
|
||||||
|
} else {
|
||||||
|
throw new AssertionError("Failed to reload systemd daemon");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user