Ignore audio entities in SpawnAndDeleteEntityCountTest (#34021)
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Robust.Shared;
|
using Robust.Shared;
|
||||||
|
using Robust.Shared.Audio.Components;
|
||||||
using Robust.Shared.Configuration;
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
@@ -216,14 +217,17 @@ namespace Content.IntegrationTests.Tests
|
|||||||
/// generally not spawn unrelated / detached entities. Any entities that do get spawned should be parented to
|
/// generally not spawn unrelated / detached entities. Any entities that do get spawned should be parented to
|
||||||
/// the spawned entity (e.g., in a container). If an entity needs to spawn an entity somewhere in null-space,
|
/// the spawned entity (e.g., in a container). If an entity needs to spawn an entity somewhere in null-space,
|
||||||
/// it should delete that entity when it is no longer required. This test mainly exists to prevent "entity leak"
|
/// it should delete that entity when it is no longer required. This test mainly exists to prevent "entity leak"
|
||||||
/// bugs, where spawning some entity starts spawning unrelated entities in null space.
|
/// bugs, where spawning some entity starts spawning unrelated entities in null space that stick around after
|
||||||
|
/// the original entity is gone.
|
||||||
|
///
|
||||||
|
/// Note that this isn't really a strict requirement, and there are probably quite a few edge cases. Its a pretty
|
||||||
|
/// crude test to try catch issues like this, and possibly should just be disabled.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Test]
|
[Test]
|
||||||
public async Task SpawnAndDeleteEntityCountTest()
|
public async Task SpawnAndDeleteEntityCountTest()
|
||||||
{
|
{
|
||||||
var settings = new PoolSettings { Connected = true, Dirty = true };
|
var settings = new PoolSettings { Connected = true, Dirty = true };
|
||||||
await using var pair = await PoolManager.GetServerClient(settings);
|
await using var pair = await PoolManager.GetServerClient(settings);
|
||||||
var mapManager = pair.Server.ResolveDependency<IMapManager>();
|
|
||||||
var mapSys = pair.Server.System<SharedMapSystem>();
|
var mapSys = pair.Server.System<SharedMapSystem>();
|
||||||
var server = pair.Server;
|
var server = pair.Server;
|
||||||
var client = pair.Client;
|
var client = pair.Client;
|
||||||
@@ -261,6 +265,9 @@ namespace Content.IntegrationTests.Tests
|
|||||||
|
|
||||||
await pair.RunTicksSync(3);
|
await pair.RunTicksSync(3);
|
||||||
|
|
||||||
|
// We consider only non-audio entities, as some entities will just play sounds when they spawn.
|
||||||
|
int Count(IEntityManager ent) => ent.EntityCount - ent.Count<AudioComponent>();
|
||||||
|
|
||||||
foreach (var protoId in protoIds)
|
foreach (var protoId in protoIds)
|
||||||
{
|
{
|
||||||
// TODO fix ninja
|
// TODO fix ninja
|
||||||
@@ -268,8 +275,8 @@ namespace Content.IntegrationTests.Tests
|
|||||||
if (protoId == "MobHumanSpaceNinja")
|
if (protoId == "MobHumanSpaceNinja")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var count = server.EntMan.EntityCount;
|
var count = Count(server.EntMan);
|
||||||
var clientCount = client.EntMan.EntityCount;
|
var clientCount = Count(client.EntMan);
|
||||||
EntityUid uid = default;
|
EntityUid uid = default;
|
||||||
await server.WaitPost(() => uid = server.EntMan.SpawnEntity(protoId, coords));
|
await server.WaitPost(() => uid = server.EntMan.SpawnEntity(protoId, coords));
|
||||||
await pair.RunTicksSync(3);
|
await pair.RunTicksSync(3);
|
||||||
@@ -277,30 +284,30 @@ namespace Content.IntegrationTests.Tests
|
|||||||
// If the entity deleted itself, check that it didn't spawn other entities
|
// If the entity deleted itself, check that it didn't spawn other entities
|
||||||
if (!server.EntMan.EntityExists(uid))
|
if (!server.EntMan.EntityExists(uid))
|
||||||
{
|
{
|
||||||
if (server.EntMan.EntityCount != count)
|
if (Count(server.EntMan) != count)
|
||||||
{
|
{
|
||||||
Assert.Fail($"Server prototype {protoId} failed on deleting itself");
|
Assert.Fail($"Server prototype {protoId} failed on deleting itself");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client.EntMan.EntityCount != clientCount)
|
if (Count(client.EntMan) != clientCount)
|
||||||
{
|
{
|
||||||
Assert.Fail($"Client prototype {protoId} failed on deleting itself\n" +
|
Assert.Fail($"Client prototype {protoId} failed on deleting itself\n" +
|
||||||
$"Expected {clientCount} and found {client.EntMan.EntityCount}.\n" +
|
$"Expected {clientCount} and found {Count(client.EntMan)}.\n" +
|
||||||
$"Server was {count}.");
|
$"Server was {count}.");
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the number of entities has increased.
|
// Check that the number of entities has increased.
|
||||||
if (server.EntMan.EntityCount <= count)
|
if (Count(server.EntMan) <= count)
|
||||||
{
|
{
|
||||||
Assert.Fail($"Server prototype {protoId} failed on spawning as entity count didn't increase");
|
Assert.Fail($"Server prototype {protoId} failed on spawning as entity count didn't increase");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client.EntMan.EntityCount <= clientCount)
|
if (Count(client.EntMan) <= clientCount)
|
||||||
{
|
{
|
||||||
Assert.Fail($"Client prototype {protoId} failed on spawning as entity count didn't increase" +
|
Assert.Fail($"Client prototype {protoId} failed on spawning as entity count didn't increase" +
|
||||||
$"Expected at least {clientCount} and found {client.EntMan.EntityCount}. " +
|
$"Expected at least {clientCount} and found {Count(client.EntMan)}. " +
|
||||||
$"Server was {count}");
|
$"Server was {count}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,15 +315,15 @@ namespace Content.IntegrationTests.Tests
|
|||||||
await pair.RunTicksSync(3);
|
await pair.RunTicksSync(3);
|
||||||
|
|
||||||
// Check that the number of entities has gone back to the original value.
|
// Check that the number of entities has gone back to the original value.
|
||||||
if (server.EntMan.EntityCount != count)
|
if (Count(server.EntMan) != count)
|
||||||
{
|
{
|
||||||
Assert.Fail($"Server prototype {protoId} failed on deletion count didn't reset properly");
|
Assert.Fail($"Server prototype {protoId} failed on deletion count didn't reset properly");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client.EntMan.EntityCount != clientCount)
|
if (Count(client.EntMan) != clientCount)
|
||||||
{
|
{
|
||||||
Assert.Fail($"Client prototype {protoId} failed on deletion count didn't reset properly:\n" +
|
Assert.Fail($"Client prototype {protoId} failed on deletion count didn't reset properly:\n" +
|
||||||
$"Expected {clientCount} and found {client.EntMan.EntityCount}.\n" +
|
$"Expected {clientCount} and found {Count(client.EntMan)}.\n" +
|
||||||
$"Server was {count}.");
|
$"Server was {count}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user