Attempt to normalize the process priority class on Windows Live tests

Also assume Windows allows nicing.
This commit is contained in:
Dominion
2023-06-02 13:46:20 -04:00
parent d94ba26151
commit 50c657ea32
2 changed files with 17 additions and 4 deletions
@@ -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<string>()
{
@@ -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;