2023-07-05 21:54:25 -07:00
2022-06-19 20:22:28 -07:00
[assembly: Parallelizable(ParallelScope.Children)]
namespace Content.IntegrationTests ;
[SetUpFixture]
public sealed class PoolManagerTestEventHandler
{
2022-12-07 19:34:58 +13:00
// This value is completely arbitrary.
2023-03-26 12:28:02 +13:00
private static TimeSpan MaximumTotalTestingTimeLimit = > TimeSpan . FromMinutes ( 20 ) ;
2022-09-15 20:17:02 -07:00
private static TimeSpan HardStopTimeLimit = > MaximumTotalTestingTimeLimit . Add ( TimeSpan . FromMinutes ( 1 ) ) ;
2023-08-05 16:16:48 +12:00
2022-09-15 20:17:02 -07:00
[OneTimeSetUp]
public void Setup ( )
{
2024-10-04 11:27:12 +03:00
PoolManager . Startup ( ) ;
2022-09-15 20:17:02 -07:00
// If the tests seem to be stuck, we try to end it semi-nicely
_ = Task . Delay ( MaximumTotalTestingTimeLimit ) . ContinueWith ( _ = >
{
2022-12-07 19:34:58 +13:00
// 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" ) ;
2022-09-15 20:17:02 -07:00
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}" ) ;
} ) ;
}
2022-06-19 20:22:28 -07:00
[OneTimeTearDown]
public void TearDown ( )
{
PoolManager . Shutdown ( ) ;
}
}