From 2da317b9b8aa1052be934b4cf35aaca1efa97aab Mon Sep 17 00:00:00 2001 From: Dominion Date: Sun, 4 Jun 2023 09:34:52 -0400 Subject: [PATCH] Extend test timeout specifically for GitHub actions --- tests/Tgstation.Server.Tests/Live/LiveTestUtils.cs | 9 +++++++++ tests/Tgstation.Server.Tests/Live/LiveTestingServer.cs | 3 +-- .../Live/RateLimitRetryingApiClient.cs | 4 ++++ tests/Tgstation.Server.Tests/Live/TestLiveServer.cs | 4 ++-- 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 tests/Tgstation.Server.Tests/Live/LiveTestUtils.cs diff --git a/tests/Tgstation.Server.Tests/Live/LiveTestUtils.cs b/tests/Tgstation.Server.Tests/Live/LiveTestUtils.cs new file mode 100644 index 0000000000..bc8814ca2f --- /dev/null +++ b/tests/Tgstation.Server.Tests/Live/LiveTestUtils.cs @@ -0,0 +1,9 @@ +using System; + +namespace Tgstation.Server.Tests.Live +{ + static class LiveTestUtils + { + public static bool RunningInGitHubActions { get; } = !String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("GITHUB_RUN_ID")); + } +} diff --git a/tests/Tgstation.Server.Tests/Live/LiveTestingServer.cs b/tests/Tgstation.Server.Tests/Live/LiveTestingServer.cs index 4aa9e70604..66e0d46e90 100644 --- a/tests/Tgstation.Server.Tests/Live/LiveTestingServer.cs +++ b/tests/Tgstation.Server.Tests/Live/LiveTestingServer.cs @@ -89,9 +89,8 @@ 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 on linux though - var runningInGitHubActions = !String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("GITHUB_RUN_ID")); var windows = new Host.System.PlatformIdentifier().IsWindows; - var nicingAllowed = windows || !runningInGitHubActions; + var nicingAllowed = windows || !LiveTestUtils.RunningInGitHubActions; HighPriorityDreamDaemon = nicingAllowed; LowPriorityDeployments = nicingAllowed; diff --git a/tests/Tgstation.Server.Tests/Live/RateLimitRetryingApiClient.cs b/tests/Tgstation.Server.Tests/Live/RateLimitRetryingApiClient.cs index c45c12dbf8..9434730bc1 100644 --- a/tests/Tgstation.Server.Tests/Live/RateLimitRetryingApiClient.cs +++ b/tests/Tgstation.Server.Tests/Live/RateLimitRetryingApiClient.cs @@ -3,6 +3,8 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; + using Tgstation.Server.Api; using Tgstation.Server.Client; using Tgstation.Server.Common; @@ -29,6 +31,8 @@ namespace Tgstation.Server.Tests.Live var now = DateTimeOffset.UtcNow; Console.WriteLine($"TEST ERROR RATE LIMITED: {ex}"); + if (!LiveTestUtils.RunningInGitHubActions) + Assert.Inconclusive("Rate limited by GitHub!"); var sleepTime = ex.RetryAfter.Value - now; Console.WriteLine($"Sleeping for {sleepTime.TotalMinutes} minutes and retrying..."); diff --git a/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs b/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs index d75a40c8ef..726f00b76e 100644 --- a/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs +++ b/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs @@ -746,8 +746,8 @@ namespace Tgstation.Server.Tests.Live Assert.AreEqual(ProcessPriorityClass.Normal, currentProcess.PriorityClass); } - const int MaximumTestMinutes = 30; - using var hardCancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMinutes(MaximumTestMinutes)); + var maximumTestMinutes = LiveTestUtils.RunningInGitHubActions ? 90 : 20; + using var hardCancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMinutes(maximumTestMinutes)); var hardCancellationToken = hardCancellationTokenSource.Token; ServiceCollectionExtensions.UseAdditionalLoggerProvider();