Skip to content

Commit

Permalink
just keep JAVA_OPTS_APPEND approach
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarranzan committed Oct 30, 2024
1 parent 281e7c6 commit 286db88
Showing 1 changed file with 3 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package io.quarkus.test.services.containers;

import java.util.Optional;

import org.apache.commons.lang3.StringUtils;
import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;

Expand All @@ -23,18 +20,6 @@ protected KeycloakGenericDockerContainerManagedResource(KeycloakContainerManaged
this.model = model;
}

// Currently, we can't properly set the container's memory limit when running with Podman.
// More details on this issue can be found here: https://github.com/quarkus-qe/quarkus-test-suite/issues/2106
private boolean isPodman() {
try {
String dockerVersion = DockerClientFactory.instance().client().versionCmd().exec().getVersion();
return dockerVersion != null && dockerVersion.toLowerCase().contains("podman");
} catch (Exception e) {
Log.warn("Failed to detect container runtime: " + e.getMessage());
return false;
}
}

@Override
protected GenericContainer<?> initContainer() {
GenericContainer<?> container = new GenericContainer<>(model.getImage());
Expand All @@ -54,12 +39,9 @@ protected GenericContainer<?> initContainer() {

container.withCreateContainerCmdModifier(cmd -> cmd.withName(DockerUtils.generateDockerContainerName()));

if (isPodman()) {
container.withEnv("JAVA_OPTS_APPEND", String.format("-XX:MaxRAM=%sm", model.getMemoryLimitMiB()));
} else {
container.withCreateContainerCmdModifier(cmd -> Optional.ofNullable(cmd.getHostConfig())
.ifPresent(config -> config.withMemory(convertMiBtoBytes(model.getMemoryLimitMiB()))));
}
// Currently, we can't properly set the container's memory limit when running with Podman.
// More details on this issue can be found here: https://github.com/quarkus-qe/quarkus-test-suite/issues/2106
container.withEnv("JAVA_OPTS_APPEND", String.format("-XX:MaxRAM=%sm", model.getMemoryLimitMiB()));

if (isReusable()) {
Log.info(model.getContext().getOwner(), "Running container on Reusable mode");
Expand Down

0 comments on commit 286db88

Please sign in to comment.