testcontainers / testcontainers/testcontainers-java
Mapped port polling on container startup causes race conditions with containers that terminate on startup
まだ誰も着手していません。
- 主要言語
- Java
- スター
- 8.7k
- フォーク
- 1.9k
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 9
説明
It appears that https://github.com/testcontainers/testcontainers-java/pull/4263 introduced some flakiness in a subset of our tests. In particular, we have a few tests that test failure conditions for a container. In those tests, we either override waitUntilContainerStarted to check for a special log message or use a OneShotStartupCheckStrategy to detect when the desired state has been achieved. However, after upgrading to a version of TestContainers that includes the PR above (in this case, from 1.15.3 to 1.17.1), we started occasionally getting failures like this:
...
Caused by: org.testcontainers.shaded.org.awaitility.core.ConditionTimeoutException: Lambda expression in org.testcontainers.containers.GenericContainer: expected the predicate to return <true> but it returned <false> for input of ...
at org.testcontainers.shaded.org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
at org.testcontainers.shaded.org.awaitility.core.AbstractHamcrestCondition.await(AbstractHamcrestCondition.java:86)
at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:985)
at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:691)
at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:708)
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:450)
at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:340)
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:338)
at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:326)
...
My belief is that, when it fails, the container terminates in between polling attempts, causing the until block to never succeed.
My expectation would be that the block to detect mapped ports should not throw an exception in this case.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
GenericContainer.java の tryStart から始め、スタックトレースと PR 4263 で導入されたマップ済みポートのポーリングを手がかりにしてください。ポーリング中にコンテナが終了する状況で、OneShotStartupCheckStrategy またはオーバーライドした waitUntilContainerStarted を使った失敗条件のテストを再現してください。マップ済みポートのポーリング試行の間にコンテナが終了したことだけを理由に、起動処理がタイムアウトしなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- docker, java
- 領域
- testing
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100