-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'testcontainers:main' into main
- Loading branch information
Showing
14 changed files
with
237 additions
and
160 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
54 changes: 54 additions & 0 deletions
54
core/src/test/java/org/testcontainers/junit/ComposeContainerWithWaitStrategies.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.testcontainers.junit; | ||
|
||
import org.junit.Test; | ||
import org.testcontainers.containers.ComposeContainer; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
|
||
import java.io.File; | ||
import java.time.Duration; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class ComposeContainerWithWaitStrategies { | ||
|
||
private static final int REDIS_PORT = 6379; | ||
|
||
@Test | ||
public void testComposeContainerConstructor() { | ||
try ( | ||
// composeContainerWithCombinedWaitStrategies { | ||
ComposeContainer compose = new ComposeContainer(new File("src/test/resources/composev2/compose-test.yml")) | ||
.withExposedService("redis-1", REDIS_PORT, Wait.forSuccessfulCommand("redis-cli ping")) | ||
.withExposedService("db-1", 3306, Wait.forLogMessage(".*ready for connections.*\\n", 1)) | ||
// } | ||
) { | ||
compose.start(); | ||
containsStartedServices(compose, "redis-1", "db-1"); | ||
} | ||
} | ||
|
||
@Test | ||
public void testComposeContainerWaitForPortWithTimeout() { | ||
try ( | ||
// composeContainerWaitForPortWithTimeout { | ||
ComposeContainer compose = new ComposeContainer(new File("src/test/resources/composev2/compose-test.yml")) | ||
.withExposedService( | ||
"redis-1", | ||
REDIS_PORT, | ||
Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(30)) | ||
) | ||
// } | ||
) { | ||
compose.start(); | ||
containsStartedServices(compose, "redis-1"); | ||
} | ||
} | ||
|
||
private void containsStartedServices(ComposeContainer compose, String... expectedServices) { | ||
for (String serviceName : expectedServices) { | ||
assertThat(compose.getContainerByServiceName(serviceName)) | ||
.as("Container should be found by service name %s", serviceName) | ||
.isPresent(); | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.