Skip to content

Commit

Permalink
Cleanup imageio cache font files, Whitelist podman
Browse files Browse the repository at this point in the history
  • Loading branch information
Karm committed Sep 7, 2023
1 parent 22a0700 commit 39f2b65
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.DebugCodeInfoUseSourceMappings_23_0;
Expand Down Expand Up @@ -646,11 +647,21 @@ public void imageioAWT(TestInfo testInfo, Apps app) throws IOException, Interrup
if (metaINF.exists()) {
FileUtils.cleanDirectory(metaINF);
}
new File(appDir, "dependency-reduced-pom.xml").delete();
final File fontConfigDir = new File(appDir, "?");
if (fontConfigDir.exists()) {
FileUtils.forceDelete(fontConfigDir);
}
Stream.of(
new File(appDir, "?"),
new File(appDir, ".cache"),
new File(appDir, ".java"),
new File(appDir, "dependency-reduced-pom.xml")
).forEach(f -> {
try {
if (f.exists()) {
FileUtils.deleteDirectory(f);
}
} catch (IOException e) {
// We ignore it...
e.printStackTrace();
}
});
controlData.keySet().forEach(f -> new File(appDir, f).delete());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,9 @@ public static boolean waitForContainerLogToMatch(String containerName, Pattern p
long timeoutMillis = unit.toMillis(timeout);
long sleepMillis = unit.toMillis(sleep);
long startMillis = System.currentTimeMillis();
final ProcessBuilder processBuilder = new ProcessBuilder(getRunCommand(CONTAINER_RUNTIME, "logs", containerName));
final List<String> cmd = getRunCommand(CONTAINER_RUNTIME, "logs", containerName);
LOGGER.infof("Command: %s", cmd);
final ProcessBuilder processBuilder = new ProcessBuilder(cmd);
final Map<String, String> envA = processBuilder.environment();
envA.put("PATH", System.getenv("PATH"));
processBuilder.redirectErrorStream(true);
Expand Down Expand Up @@ -431,6 +433,7 @@ public static void stopRunningContainers(String... containerNames) throws Interr

public static void stopRunningContainer(String containerName) throws InterruptedException, IOException {
final List<String> cmd = new ArrayList<>(getRunCommand(CONTAINER_RUNTIME, "stop", containerName));
LOGGER.infof("Command: %s", cmd);
final Process process = Runtime.getRuntime().exec(cmd.toArray(String[]::new));
process.waitFor(5, TimeUnit.SECONDS);
}
Expand All @@ -443,6 +446,7 @@ public static void removeContainers(String... containerNames) throws Interrupted

public static void removeContainer(String containerName) throws InterruptedException, IOException {
final List<String> cmd = new ArrayList<>(getRunCommand(CONTAINER_RUNTIME, "rm", containerName, "--force"));
LOGGER.infof("Command: %s", cmd);
final Process process = Runtime.getRuntime().exec(cmd.toArray(String[]::new));
process.waitFor(5, TimeUnit.SECONDS);
}
Expand All @@ -456,8 +460,10 @@ public static void removeContainer(String containerName) throws InterruptedExcep
13.43MiB / 11.28GiB
*/
public static long getContainerMemoryKb(String containerName) throws IOException, InterruptedException {
final ProcessBuilder pa = new ProcessBuilder(getRunCommand(
CONTAINER_RUNTIME, "stats", "--no-stream", "--format", "table {{.MemUsage}}", containerName));
final List<String> cmd = getRunCommand(
CONTAINER_RUNTIME, "stats", "--no-stream", "--format", "table {{.MemUsage}}", containerName);
LOGGER.infof("Command: %s", cmd);
final ProcessBuilder pa = new ProcessBuilder(cmd);
final Map<String, String> envA = pa.environment();
envA.put("PATH", System.getenv("PATH"));
pa.redirectErrorStream(true);
Expand All @@ -468,6 +474,10 @@ public static long getContainerMemoryKb(String containerName) throws IOException
while ((l = processOutputReader.readLine()) != null) {
if (l.contains("Error")) {
LOGGER.error("Container: " + l);
if (l.contains("No such container: {{.MemUsage}}")) {
LOGGER.error("You don't have the right to call `stats' on " + containerName + " container. " +
"You might have to set " + ("podman".equals(CONTAINER_RUNTIME) ? "PODMAN_WITH_SUDO" : "DOCKER_WITH_SUDO") + " to true.");
}
break;
}
final Matcher m = CONTAINER_STATS_MEMORY.matcher(l);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ public Pattern[] get(boolean inContainer) {
Pattern.compile(".*ControllerVerticle] Uncaught error: java.lang.NullPointerException.*"),
// For some reason, Podman spits this when terminating Hyperfoil containers
Pattern.compile(".*Could not retrieve exit code from event: died not found: unable to find event.*"),
// Again Hyperfoil and Podman. There might be something odd with stopping those agents? Not a Quaruks/Mandrel issue.
Pattern.compile(".*Waiting for container .* getting exit code of container .* from DB: no such exit code \\(container in state running\\).*"),
// Quarkus 3.x intermittently with JDK 20 based build...
Pattern.compile(".*io.net.boo.ServerBootstrap.*Failed to register an accepted channel:.*")
};
Expand Down

0 comments on commit 39f2b65

Please sign in to comment.