From d6a0895ffc9c9a5ca275c88d1229beeca09effbe Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Sat, 16 Nov 2024 10:49:08 +0100 Subject: [PATCH] fix: Add HTTP wait strategy to prevent race-condition in TarOutputMemoryStreamTest --- src/Testcontainers.WebDriver/WebDriverBuilder.cs | 4 ++-- .../TarOutputMemoryStreamTest.cs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Testcontainers.WebDriver/WebDriverBuilder.cs b/src/Testcontainers.WebDriver/WebDriverBuilder.cs index 8a99ba216..4ec108ecc 100644 --- a/src/Testcontainers.WebDriver/WebDriverBuilder.cs +++ b/src/Testcontainers.WebDriver/WebDriverBuilder.cs @@ -100,8 +100,8 @@ protected override WebDriverBuilder Init() .WithNetworkAliases(WebDriverNetworkAlias) .WithPortBinding(WebDriverPort, true) .WithPortBinding(VncServerPort, true) - .WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request - => request.ForPath("/wd/hub/status").ForPort(WebDriverPort).ForResponseMessageMatching(IsGridReadyAsync))); + .WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request => + request.ForPath("/wd/hub/status").ForPort(WebDriverPort).ForResponseMessageMatching(IsGridReadyAsync))); } /// diff --git a/tests/Testcontainers.Platform.Linux.Tests/TarOutputMemoryStreamTest.cs b/tests/Testcontainers.Platform.Linux.Tests/TarOutputMemoryStreamTest.cs index 46b810995..220175ba1 100644 --- a/tests/Testcontainers.Platform.Linux.Tests/TarOutputMemoryStreamTest.cs +++ b/tests/Testcontainers.Platform.Linux.Tests/TarOutputMemoryStreamTest.cs @@ -176,6 +176,8 @@ public sealed class HttpFixture : IAsyncLifetime .WithEntrypoint("/bin/sh", "-c") .WithCommand($"while true; do echo \"HTTP/1.1 200 OK\r\n\r\n\" | nc -l -p {HttpPort}; done") .WithPortBinding(HttpPort, true) + .WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request => + request.ForPath("/"))) .Build(); public string BaseAddress