This is the content analogue of https://github.com/space-wizards/RobustToolbox/pull/5412 Made Content.Tests run tests parallelized, which doesn't really seem to matter much. I tried to make Content.IntegrationTest more aggressively parallelized but ran into https://github.com/dotnet/runtime/issues/107197 so we need to shelve that. Added a comment explaining as such.
36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
namespace Content.IntegrationTests;
|
|
|
|
[SetUpFixture]
|
|
public sealed class PoolManagerTestEventHandler
|
|
{
|
|
// This value is completely arbitrary.
|
|
private static TimeSpan MaximumTotalTestingTimeLimit => TimeSpan.FromMinutes(20);
|
|
private static TimeSpan HardStopTimeLimit => MaximumTotalTestingTimeLimit.Add(TimeSpan.FromMinutes(1));
|
|
|
|
[OneTimeSetUp]
|
|
public void Setup()
|
|
{
|
|
PoolManager.Startup();
|
|
// If the tests seem to be stuck, we try to end it semi-nicely
|
|
_ = Task.Delay(MaximumTotalTestingTimeLimit).ContinueWith(_ =>
|
|
{
|
|
// This can and probably will cause server/client pairs to shut down MID test, and will lead to really confusing test failures.
|
|
TestContext.Error.WriteLine($"\n\n{nameof(PoolManagerTestEventHandler)}: ERROR: Tests are taking too long. Shutting down all tests. This may lead to weird failures/exceptions.\n\n");
|
|
PoolManager.Shutdown();
|
|
});
|
|
|
|
// If ending it nicely doesn't work within a minute, we do something a bit meaner.
|
|
_ = Task.Delay(HardStopTimeLimit).ContinueWith(_ =>
|
|
{
|
|
var deathReport = PoolManager.DeathReport();
|
|
Environment.FailFast($"Tests took way too ;\n Death Report:\n{deathReport}");
|
|
});
|
|
}
|
|
|
|
[OneTimeTearDown]
|
|
public void TearDown()
|
|
{
|
|
PoolManager.Shutdown();
|
|
}
|
|
}
|