-
-
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.
Added withLogConsumer() method to DockerComposeContainer (#629)
* Added withLogConsumer() method to DockerComposeContainer Fixes #605 * Added try-finally block to DockerComposeLogConsumerTest
- Loading branch information
1 parent
2cb1429
commit cacf0bc
Showing
3 changed files
with
62 additions
and
3 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
30 changes: 30 additions & 0 deletions
30
core/src/test/java/org/testcontainers/junit/DockerComposeLogConsumerTest.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,30 @@ | ||
package org.testcontainers.junit; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.Description; | ||
import org.testcontainers.containers.DockerComposeContainer; | ||
import org.testcontainers.containers.output.WaitingConsumer; | ||
|
||
import java.io.File; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
import static org.testcontainers.containers.output.OutputFrame.OutputType.STDOUT; | ||
|
||
public class DockerComposeLogConsumerTest { | ||
|
||
@Test | ||
public void testLogConsumer() throws TimeoutException { | ||
WaitingConsumer logConsumer = new WaitingConsumer(); | ||
DockerComposeContainer environment = new DockerComposeContainer(new File("src/test/resources/v2-compose-test.yml")) | ||
.withExposedService("redis_1", 6379) | ||
.withLogConsumer("redis_1", logConsumer); | ||
|
||
try { | ||
environment.starting(Description.EMPTY); | ||
logConsumer.waitUntil(frame -> frame.getType() == STDOUT && frame.getUtf8String().contains("Ready to accept connections"), 5, TimeUnit.SECONDS); | ||
} finally { | ||
environment.finished(Description.EMPTY); | ||
} | ||
} | ||
} |