Skip to content

Commit

Permalink
Kill tests when can't make test pair (#10861)
Browse files Browse the repository at this point in the history
  • Loading branch information
wrexbe authored Aug 25, 2022
1 parent c9f43f3 commit e0de167
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions Content.IntegrationTests/PoolManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private static readonly (string cvar, string value, bool tryAdd)[] ServerTestCva
private static int PairId;
private static object PairLock = new();
private static List<Pair> Pairs = new();
private static Exception PoolFailureReason;

private static async Task ConfigurePrototypes(RobustIntegrationTest.IntegrationInstance instance,
PoolSettings settings)
Expand Down Expand Up @@ -410,10 +411,27 @@ await pair.Client.WaitPost(() =>

private static async Task<Pair> CreateServerClientPair(PoolSettings poolSettings)
{
var client = await GenerateClient(poolSettings);
var server = await GenerateServer(poolSettings);
Pair pair;
if (PoolFailureReason != null)
{
Assert.Inconclusive(@"
In a different test, the pool manager had an exception when trying to create a server/client pair.
Instead of risking that the pool manager will fail at creating a server/client pairs for every single test,
we are just going to end this here to save a lot of time. This is the exception that started this:\n {0}", PoolFailureReason);
}

try
{
var client = await GenerateClient(poolSettings);
var server = await GenerateServer(poolSettings);
pair = new Pair { Server = server, Client = client, PairId = Interlocked.Increment(ref PairId) };
}
catch (Exception ex)
{
PoolFailureReason = ex;
throw;
}

var pair = new Pair { Server = server, Client = client, PairId = Interlocked.Increment(ref PairId)};
if (!poolSettings.NotConnected)
{
pair.Client.SetConnectTarget(pair.Server);
Expand All @@ -426,7 +444,7 @@ await pair.Client.WaitPost(() =>
}
});
await ReallyBeIdle(pair, 10);
await client.WaitRunTicks(1);
await pair.Client.WaitRunTicks(1);
}
return pair;
}
Expand Down

0 comments on commit e0de167

Please sign in to comment.