From 50c657ea32bfe76655599dd90f45f4af408ad050 Mon Sep 17 00:00:00 2001 From: Dominion Date: Fri, 2 Jun 2023 12:39:38 -0400 Subject: [PATCH] Attempt to normalize the process priority class on Windows Live tests Also assume Windows allows nicing. --- .../Tgstation.Server.Tests/Live/LiveTestingServer.cs | 10 ++++++---- tests/Tgstation.Server.Tests/Live/TestLiveServer.cs | 11 +++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/Tgstation.Server.Tests/Live/LiveTestingServer.cs b/tests/Tgstation.Server.Tests/Live/LiveTestingServer.cs index d4fd75b758..6a66269efb 100644 --- a/tests/Tgstation.Server.Tests/Live/LiveTestingServer.cs +++ b/tests/Tgstation.Server.Tests/Live/LiveTestingServer.cs @@ -88,10 +88,12 @@ namespace Tgstation.Server.Tests.Live // neither of these should really matter but it's better that we test them // high prio DD might help with some topic flakiness actually - // github doesn't allow nicing though - bool runningInGitHubActions = !String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("GITHUB_RUN_ID")); - HighPriorityDreamDaemon = !runningInGitHubActions; - LowPriorityDeployments = !runningInGitHubActions; + // github doesn't allow nicing on linux though + var runningInGitHubActions = !String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("GITHUB_RUN_ID")); + var windows = new Host.System.PlatformIdentifier().IsWindows; + var nicingAllowed = windows || !runningInGitHubActions; + HighPriorityDreamDaemon = nicingAllowed; + LowPriorityDeployments = nicingAllowed; args = new List() { diff --git a/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs b/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs index 10569c914c..678e361897 100644 --- a/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs +++ b/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs @@ -730,6 +730,17 @@ namespace Tgstation.Server.Tests.Live [TestMethod] public async Task TestStandardTgsOperation() { + using(var currentProcess = System.Diagnostics.Process.GetCurrentProcess()) + { + var currentPriorityClass = currentProcess.PriorityClass; + if (currentPriorityClass != ProcessPriorityClass.Normal) + { + // attempt to adjust it + Console.WriteLine($"TEST PROCESS PRIORITY: Attempting to normalize process priority from {currentPriorityClass}..."); + currentProcess.PriorityClass = ProcessPriorityClass.Normal; + } + } + const int MaximumTestMinutes = 30; using var hardCancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMinutes(MaximumTestMinutes)); var hardCancellationToken = hardCancellationTokenSource.Token;