diff --git a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs index 42caa60be5..b215a9fab3 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs @@ -556,59 +556,57 @@ namespace Tgstation.Server.Tests.Live.Instance File.Delete(dumpFiles.Single()); // fuck this test, it's flakey as a motherfucker - if (Environment.NewLine != null) + if (Environment.NewLine == null) { - return; - } + // failed dump + JobResponse job; + while (true) + { + KillDD(true); + var jobTcs = new TaskCompletionSource(); + var killTaskStarted = new TaskCompletionSource(); + var killThread = new Thread(() => + { + killTaskStarted.SetResult(); + while (!jobTcs.Task.IsCompleted) + KillDD(false); + }) + { + Priority = ThreadPriority.AboveNormal + }; - // failed dump - JobResponse job; - while (true) - { - KillDD(true); - var jobTcs = new TaskCompletionSource(); - var killTaskStarted = new TaskCompletionSource(); - var killThread = new Thread(() => - { - killTaskStarted.SetResult(); - while (!jobTcs.Task.IsCompleted) - KillDD(false); - }) - { - Priority = ThreadPriority.AboveNormal - }; + killThread.Start(); + try + { + await killTaskStarted.Task; + var dumpTask = instanceClient.DreamDaemon.CreateDump(cancellationToken); + job = await WaitForJob(await dumpTask, 20, true, null, cancellationToken); + } + finally + { + jobTcs.SetResult(); + killThread.Join(); + } - killThread.Start(); - try - { - await killTaskStarted.Task; - var dumpTask = instanceClient.DreamDaemon.CreateDump(cancellationToken); - job = await WaitForJob(await dumpTask, 20, true, null, cancellationToken); - } - finally - { - jobTcs.SetResult(); - killThread.Join(); + // these can also happen + + if (!(new PlatformIdentifier().IsWindows + && (job.ExceptionDetails.Contains("Access is denied.") + || job.ExceptionDetails.Contains("The handle is invalid.") + || job.ExceptionDetails.Contains("Unknown error") + || job.ExceptionDetails.Contains("No process is associated with this object.") + || job.ExceptionDetails.Contains("The program issued a command but the command length is incorrect.") + || job.ExceptionDetails.Contains("Only part of a ReadProcessMemory or WriteProcessMemory request was completed.") + || job.ExceptionDetails.Contains("Unknown error")))) + break; + + var restartJob = await instanceClient.DreamDaemon.Restart(cancellationToken); + await WaitForJob(restartJob, 20, false, null, cancellationToken); } - // these can also happen - - if (!(new PlatformIdentifier().IsWindows - && (job.ExceptionDetails.Contains("Access is denied.") - || job.ExceptionDetails.Contains("The handle is invalid.") - || job.ExceptionDetails.Contains("Unknown error") - || job.ExceptionDetails.Contains("No process is associated with this object.") - || job.ExceptionDetails.Contains("The program issued a command but the command length is incorrect.") - || job.ExceptionDetails.Contains("Only part of a ReadProcessMemory or WriteProcessMemory request was completed.") - || job.ExceptionDetails.Contains("Unknown error")))) - break; - - var restartJob = await instanceClient.DreamDaemon.Restart(cancellationToken); - await WaitForJob(restartJob, 20, false, null, cancellationToken); + Assert.IsTrue(job.ErrorCode == ErrorCode.GameServerOffline || job.ErrorCode == ErrorCode.GCoreFailure, $"{job.ErrorCode}: {job.ExceptionDetails}"); } - Assert.IsTrue(job.ErrorCode == ErrorCode.GameServerOffline || job.ErrorCode == ErrorCode.GCoreFailure, $"{job.ErrorCode}: {job.ExceptionDetails}"); - var restartJob2 = await instanceClient.DreamDaemon.Restart(cancellationToken); await WaitForJob(restartJob2, 20, false, null, cancellationToken); }