Skip to content

Commit df6c38a

Browse files
committed
Wait a few seconds for InternalCommandPortListeningCheck to pass
1 parent 4df12fc commit df6c38a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

core/src/test/java/org/testcontainers/containers/wait/internal/InternalCommandPortListeningCheckTest.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package org.testcontainers.containers.wait.internal;
22

33
import com.google.common.collect.ImmutableSet;
4-
import org.junit.After;
5-
import org.junit.Before;
64
import org.junit.Rule;
75
import org.junit.Test;
86
import org.junit.runner.RunWith;
97
import org.junit.runners.Parameterized;
8+
import org.rnorth.ducttape.TimeoutException;
9+
import org.rnorth.ducttape.unreliables.Unreliables;
1010
import org.testcontainers.containers.GenericContainer;
1111
import org.testcontainers.images.builder.ImageFromDockerfile;
1212

13+
import java.util.concurrent.TimeUnit;
14+
1315
import static java.util.Arrays.asList;
1416
import static org.rnorth.visibleassertions.VisibleAssertions.assertFalse;
1517
import static org.rnorth.visibleassertions.VisibleAssertions.assertTrue;
@@ -41,6 +43,8 @@ public InternalCommandPortListeningCheckTest(String dockerfile) {
4143
public void singleListening() {
4244
final InternalCommandPortListeningCheck check = new InternalCommandPortListeningCheck(container, ImmutableSet.of(8080));
4345

46+
Unreliables.retryUntilTrue(5, TimeUnit.SECONDS, check);
47+
4448
final Boolean result = check.call();
4549

4650
assertTrue("InternalCommandPortListeningCheck identifies a single listening port", result);
@@ -50,6 +54,12 @@ public void singleListening() {
5054
public void nonListening() {
5155
final InternalCommandPortListeningCheck check = new InternalCommandPortListeningCheck(container, ImmutableSet.of(8080, 1234));
5256

57+
try {
58+
Unreliables.retryUntilTrue(5, TimeUnit.SECONDS, check);
59+
} catch (TimeoutException e) {
60+
// we expect it to timeout
61+
}
62+
5363
final Boolean result = check.call();
5464

5565
assertFalse("InternalCommandPortListeningCheck detects a non-listening port among many", result);
@@ -59,6 +69,8 @@ public void nonListening() {
5969
public void lowAndHighPortListening() {
6070
final InternalCommandPortListeningCheck check = new InternalCommandPortListeningCheck(container, ImmutableSet.of(100, 8080));
6171

72+
Unreliables.retryUntilTrue(5, TimeUnit.SECONDS, check);
73+
6274
final Boolean result = check.call();
6375

6476
assertTrue("InternalCommandPortListeningCheck identifies a low and a high port", result);

0 commit comments

Comments
 (0)