Created
August 15, 2023 13:41
-
-
Save kiview/d7380bdf05a17bc1faa454278b79a80b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.testcontainers; | |
import org.assertj.core.api.Assertions; | |
import org.junit.Test; | |
import org.testcontainers.containers.GenericContainer; | |
import org.testcontainers.containers.startupcheck.OneShotStartupCheckStrategy; | |
public class JavaGCTest { | |
@Test | |
public void shouldUseG1GC() { | |
try (GenericContainer<?> java = new GenericContainer<>("eclipse-temurin:17-jdk-focal") | |
.withStartupCheckStrategy(new OneShotStartupCheckStrategy()) | |
.withCommand("java", "-XX:+PrintFlagsFinal", "-version") | |
.withCreateContainerCmdModifier(cmd -> cmd.getHostConfig().withMemory(1024L * 1024L * 2000))) { | |
java.start(); | |
String logs = java.getLogs(); | |
Assertions.assertThat(logs).containsPattern(".*G1GC.*true.*"); | |
} | |
} | |
@Test | |
public void shouldUseSerialGc() { | |
try (GenericContainer<?> java = new GenericContainer<>("eclipse-temurin:17-jdk-focal") | |
.withStartupCheckStrategy(new OneShotStartupCheckStrategy()) | |
.withCommand("java", "-XX:+PrintFlagsFinal", "-version") | |
.withCreateContainerCmdModifier(cmd -> cmd.getHostConfig().withMemory(1024L * 1024L * 1000))) { | |
java.start(); | |
String logs = java.getLogs(); | |
Assertions.assertThat(logs).containsPattern(".*SerialGC.*true.*"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment