From 1b56dce401ce9702cf4bfe4f53d30febae57e16b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 3 Aug 2025 10:07:48 -0400 Subject: [PATCH] Fix port reselection --- .../Live/Instance/InstanceTest.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/Tgstation.Server.Tests/Live/Instance/InstanceTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/InstanceTest.cs index ab94a4b8cc..164bff1b7e 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/InstanceTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/InstanceTest.cs @@ -169,20 +169,21 @@ namespace Tgstation.Server.Tests.Live.Instance async Task UpdateDMSettings() { - for (var i = 0; i < 10; ++i) + const int Limit = 10; + for (var i = 0; i < Limit; ++i) try { - global::System.Console.WriteLine($"PORT REUSE BUG 6: Setting I-{instanceClient.Metadata.Id} DM to {dmPort}"); + if (i != 0) + { + global::System.Console.WriteLine($"PORT REUSE BUG 6: Setting I-{instanceClient.Metadata.Id} DM to {dmPort}"); + } await instanceClient.DreamMaker.Update(new DreamMakerRequest { ApiValidationPort = dmPort, }, cancellationToken); } - catch (ConflictException ex) when (ex.ErrorCode == ErrorCode.PortNotAvailable) + catch (ConflictException ex) when (ex.ErrorCode == ErrorCode.PortNotAvailable && i < (Limit - 1)) { - if (i == 4) - throw; - // I have no idea why this happens sometimes await Task.Delay(TimeSpan.FromSeconds(3), cancellationToken); }