Add test pooling (#4961)

* Add test pooling

* WIP test pooling changes

* Fix Destructible tests

* Don't pool unpooled or dummy ticker instances

* Change ServerPathfindingDebugSystem to replace existing entries

* Fix SaveLoadSaveTest comment

* Don't pool StartTest

* Comment out global setup

* Fix puddle tests

* Move SolarPanelComponent initialize to PowerSolarSystem OnMapInit

* Update RobustToolbox

* Finish fixing tests, make test threads background threads

* Bring back pooling

* Fix nullable

* Update RobustToolbox

* Set cvars on server return

* Un-pool tests with custom cvars

* Update RobustToolbox

* Update RobustToolbox

* Change where the main tile coordinates are

* Remove DisposalUnitTest grid check

* Fix test pooling being a fickle bitch

* Fix EntitySystemExtensionsTest

* Update RobustToolbox

* Update RobustToolbox

* Make nullable pool settings true

* Update RobustToolbox

* Wait other way around

* We are unitystation now

* Update RobustToolbox

* Create global setup

* Pool some more tests

* Fix not properly disconnecting clients before restarting the round

* Give more info on ran tests

* Standardize default test cvars

* Update RobustToolbox

* Update RobustToolbox

* Pool clients

* Fix test order issue

* Fix cvars in character creation test not being set properly

* Update RobustToolbox

* Update RobustToolbox

* Rider shut

* Update RobustToolbox

* Format tests ran better

* Update RobustToolbox

* Reset RobustToolbox

* Reset RobustToolbox harder

* Fix one instance of test order causing destructible tests to fail
This commit is contained in:
Javier Guardia Fernández
2021-11-06 11:49:59 +01:00
committed by GitHub
parent 4b5168e1fe
commit 1508efff54
55 changed files with 364 additions and 267 deletions

View File

@@ -5,7 +5,6 @@ using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using static Content.IntegrationTests.Tests.Destructible.DestructibleTestPrototypes;
@@ -20,7 +19,7 @@ namespace Content.IntegrationTests.Tests.Destructible
[Test]
public async Task AndTest()
{
var server = StartServerDummyTicker(new ServerContentIntegrationOption
var server = StartServer(new ServerContentIntegrationOption
{
ExtraPrototypes = Prototypes
});
@@ -39,13 +38,15 @@ namespace Content.IntegrationTests.Tests.Destructible
await server.WaitPost(() =>
{
var mapId = new MapId(1);
var coordinates = new MapCoordinates(0, 0, mapId);
sMapManager.CreateMap(mapId);
var gridId = GetMainGrid(sMapManager).GridEntityId;
var coordinates = new EntityCoordinates(gridId, 0, 0);
sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDamageGroupEntityId, coordinates);
sDamageableComponent = sDestructibleEntity.GetComponent<DamageableComponent>();
sTestThresholdListenerSystem = sEntitySystemManager.GetEntitySystem<TestDestructibleListenerSystem>();
sTestThresholdListenerSystem.ThresholdsReached.Clear();
sDamageableSystem = sEntitySystemManager.GetEntitySystem<DamageableSystem>();
});

View File

@@ -19,7 +19,7 @@ namespace Content.IntegrationTests.Tests.Destructible
[Test]
public async Task Test()
{
var server = StartServerDummyTicker(new ServerContentIntegrationOption
var server = StartServer(new ServerContentIntegrationOption
{
ExtraPrototypes = Prototypes
});
@@ -37,9 +37,8 @@ namespace Content.IntegrationTests.Tests.Destructible
await server.WaitPost(() =>
{
var mapId = new MapId(1);
var coordinates = new MapCoordinates(0, 0, mapId);
sMapManager.CreateMap(mapId);
var gridId = GetMainGrid(sMapManager).GridEntityId;
var coordinates = new EntityCoordinates(gridId, 0, 0);
sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDamageTypeEntityId, coordinates);
sDamageableComponent = sDestructibleEntity.GetComponent<DamageableComponent>();

View File

@@ -18,7 +18,7 @@ namespace Content.IntegrationTests.Tests.Destructible
[Test]
public async Task Test()
{
var server = StartServerDummyTicker(new ServerContentIntegrationOption
var server = StartServer(new ServerContentIntegrationOption
{
ExtraPrototypes = Prototypes
});
@@ -36,9 +36,8 @@ namespace Content.IntegrationTests.Tests.Destructible
await server.WaitPost(() =>
{
var mapId = new MapId(1);
var coordinates = new MapCoordinates(0, 0, mapId);
sMapManager.CreateMap(mapId);
var gridId = GetMainGrid(sMapManager).GridEntityId;
var coordinates = new EntityCoordinates(gridId, 0, 0);
sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDestructionEntityId, coordinates);
sDamageableComponent = sDestructibleEntity.GetComponent<DamageableComponent>();

View File

@@ -9,7 +9,6 @@ using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using static Content.IntegrationTests.Tests.Destructible.DestructibleTestPrototypes;
@@ -24,7 +23,7 @@ namespace Content.IntegrationTests.Tests.Destructible
[Test]
public async Task Test()
{
var server = StartServerDummyTicker(new ServerContentIntegrationOption
var server = StartServer(new ServerContentIntegrationOption
{
ExtraPrototypes = Prototypes
});
@@ -44,14 +43,16 @@ namespace Content.IntegrationTests.Tests.Destructible
await server.WaitPost(() =>
{
var mapId = new MapId(1);
var coordinates = new MapCoordinates(0, 0, mapId);
sMapManager.CreateMap(mapId);
var gridId = GetMainGrid(sMapManager).GridEntityId;
var coordinates = new EntityCoordinates(gridId, 0, 0);
sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleEntityId, coordinates);
sDamageableComponent = sDestructibleEntity.GetComponent<DamageableComponent>();
sDestructibleComponent = sDestructibleEntity.GetComponent<DestructibleComponent>();
sTestThresholdListenerSystem = sEntitySystemManager.GetEntitySystem<TestDestructibleListenerSystem>();
sTestThresholdListenerSystem.ThresholdsReached.Clear();
sDamageableSystem = sEntitySystemManager.GetEntitySystem<DamageableSystem>();
});

View File

@@ -1,6 +1,7 @@
using Content.Server.Destructible;
using Robust.Shared.GameObjects;
using System.Collections.Generic;
using Content.Server.Destructible;
using Content.Shared.GameTicking;
using Robust.Shared.GameObjects;
namespace Content.IntegrationTests.Tests.Destructible
{
@@ -10,10 +11,13 @@ namespace Content.IntegrationTests.Tests.Destructible
/// </summary>
public class TestDestructibleListenerSystem : EntitySystem
{
public readonly List<DamageThresholdReached> ThresholdsReached = new();
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DestructibleComponent, DamageThresholdReached>(AddThresholdsToList);
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
}
public void AddThresholdsToList(EntityUid _, DestructibleComponent comp, DamageThresholdReached args)
@@ -21,6 +25,9 @@ namespace Content.IntegrationTests.Tests.Destructible
ThresholdsReached.Add(args);
}
public List<DamageThresholdReached> ThresholdsReached = new();
private void OnRoundRestart(RoundRestartCleanupEvent ev)
{
ThresholdsReached.Clear();
}
}
}