From acc8a1472fd472132c3d1afe0777150bc643b7b7 Mon Sep 17 00:00:00 2001 From: shelajev Date: Mon, 23 Sep 2024 16:11:55 +0300 Subject: [PATCH] added resource limiting --- src/test/java/com/testcontainers/TestMain.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/testcontainers/TestMain.java b/src/test/java/com/testcontainers/TestMain.java index f66e308..96600fa 100644 --- a/src/test/java/com/testcontainers/TestMain.java +++ b/src/test/java/com/testcontainers/TestMain.java @@ -1,5 +1,6 @@ package com.testcontainers; +import com.github.dockerjava.api.model.HostConfig; import com.testcontainers.fun.awaitility.CloudflaredContainer; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.KafkaContainer; @@ -50,7 +51,14 @@ public static void main(String[] args) { .withEnv("SPRING_CLOUD_AWS_ENDPOINT", "localstack:4566") .withNetwork(network) - .waitingFor(Wait.forHttp("/actuator/health")); + .waitingFor(Wait.forHttp("/actuator/health")) + .withCreateContainerCmdModifier(createContainerCmd -> { + var hostConfig = new HostConfig(); + hostConfig.withMemory(1 * 1024L * 1024L); + hostConfig.withCpuCount(1L); + createContainerCmd.withHostConfig(hostConfig); + } + ); Startables.deepStart(postgres, kafka, localStack).join();