-
-
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.
Co-authored-by: Eddú Meléndez Gonzales <[email protected]>
- Loading branch information
1 parent
87bf5bf
commit de3d2d3
Showing
5 changed files
with
140 additions
and
113 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
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