Fix DummyChatProvider interference with health check tests

This commit is contained in:
Jordan Dominion
2023-12-17 17:07:02 -05:00
parent 93da4d8766
commit 638418534e
2 changed files with 16 additions and 0 deletions
@@ -44,6 +44,8 @@ namespace Tgstation.Server.Tests.Live
ulong channelIdAllocator;
public static Task MessageGuard = Task.CompletedTask;
static IAsyncDelayer CreateMockDelayer()
{
// at time of writing, this is used exclusively for the reconnection interval which works in minutes
@@ -219,6 +221,8 @@ namespace Tgstation.Server.Tests.Live
var delay = random.Next(0, 10000);
await Task.Delay(delay, cancellationToken);
await MessageGuard;
// %5 chance to disconnect randomly
if (enableRandomDisconnections != 0 && random.Next(0, 100) > 95)
connected = false;
@@ -165,9 +165,21 @@ namespace Tgstation.Server.Tests.Live.Instance
await RunLongRunningTestThenUpdateWithNewDme(cancellationToken);
await RunLongRunningTestThenUpdateWithByondVersionSwitch(cancellationToken);
// no chatty bullshit while we test health checks
var tcs = new TaskCompletionSource();
var oldTask = Interlocked.Exchange(ref DummyChatProvider.MessageGuard, tcs.Task);
await RunHealthCheckTest(true, cancellationToken);
await RunHealthCheckTest(false, cancellationToken);
async void Cleanup()
{
await oldTask;
tcs.SetResult();
}
Cleanup();
await InteropTestsForLongRunningDme(cancellationToken);
await instanceClient.DreamDaemon.Update(new DreamDaemonRequest