Skip to content

Commit fe5011c

Browse files
tippmar-nrclaude
andcommitted
test: improve docker compose retry for transient network failures
Increase max retries from 1 to 2 and add a 5-second delay between cleanup and retry to give Docker time to fully release network resources. Addresses flaky LinuxUnicodeSpecialCharactersTest failures where docker compose up gets "network not found" due to Docker daemon race conditions when multiple compose projects are active. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d63e16a commit fe5011c

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

tests/Agent/IntegrationTests/ContainerIntegrationTests/Applications/ContainerApplication.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,19 @@ protected override void WaitForProcessToStartListening(bool captureStandardOutpu
265265

266266
Console.WriteLine($"[{AppName} {DateTime.Now}] Did not find PID file matching {pidFilePath}. {(RemoteProcess.HasExited ? "Process exited" : "Wait timed out")}.");
267267

268-
// Retry once if compose exited quickly (often due to transient network creation issues)
269-
if (RemoteProcess.HasExited && _startupAttempts == 0)
268+
// Retry if compose exited quickly (often due to transient Docker network issues
269+
// where the daemon hasn't fully released resources from a prior compose project).
270+
const int maxRetries = 2;
271+
if (RemoteProcess.HasExited && _startupAttempts < maxRetries)
270272
{
271273
_startupAttempts++;
272-
Console.WriteLine($"[{AppName} {DateTime.Now}] Early compose exit detected. Retrying docker compose up (attempt {_startupAttempts}).");
274+
Console.WriteLine($"[{AppName} {DateTime.Now}] Early compose exit detected. Retrying docker compose up (attempt {_startupAttempts} of {maxRetries}).");
273275
TestLogger?.WriteLine($"[{AppName}] Retrying docker compose up.");
274276
CleanupContainer();
277+
278+
// Give Docker time to fully release network resources before retrying
279+
Thread.Sleep(TimeSpan.FromSeconds(5));
280+
275281
try
276282
{
277283
var startInfo = new ProcessStartInfo

0 commit comments

Comments
 (0)