-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove withPublishAllPorts from Ryuk and stabilize containerInfo cont…
…ent on start (#4263) `containerInfo` is queried until all ports expected by Testcontainers are mapped. Introduces Awaitility for retry logic. Removing `withPublishAllPorts` is especially important because else this can lead to publishing of excluded ports on Windows Co-authored-by: Sergei Egorov <bsideup@gmail.com>
- Loading branch information
Showing
6 changed files
with
137 additions
and
10 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
42 changes: 42 additions & 0 deletions
42
core/src/main/java/org/testcontainers/utility/DynamicPollInterval.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,42 @@ | ||
package org.testcontainers.utility; | ||
|
||
import org.awaitility.pollinterval.PollInterval; | ||
|
||
import java.time.Duration; | ||
import java.time.Instant; | ||
|
||
/** | ||
* Awaitility {@link org.awaitility.pollinterval.PollInterval} that takes execution time into consideration, | ||
* to allow a constant poll-interval, as opposed to Awaitility's default poll-delay behaviour. | ||
* | ||
* @deprecated For internal usage only. | ||
*/ | ||
@Deprecated | ||
public class DynamicPollInterval implements PollInterval { | ||
|
||
final Duration interval; | ||
Instant lastTimestamp; | ||
|
||
private DynamicPollInterval(Duration interval) { | ||
this.interval = interval; | ||
lastTimestamp = Instant.now(); | ||
} | ||
|
||
public static DynamicPollInterval of(Duration duration) { | ||
return new DynamicPollInterval(duration); | ||
} | ||
|
||
public static DynamicPollInterval ofMillis(long millis) { | ||
return DynamicPollInterval.of(Duration.ofMillis(millis)); | ||
} | ||
|
||
@Override | ||
public Duration next(int pollCount, Duration previousDuration) { | ||
Instant now = Instant.now(); | ||
Duration executionDuration = Duration.between(lastTimestamp, now); | ||
|
||
Duration result = interval.minusMillis(Math.min(interval.toMillis(), executionDuration.toMillis())); | ||
lastTimestamp = now.plus(result); | ||
return result; | ||
} | ||
} |
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