Skip to content

Commit 89a825f

Browse files
fix: Extended UniversalRpcTests run times (#3560)
This PR condenses the total number of tests from roughly ~10k down to ~3.5k by grouping like test types and migrating all `[Values]` decorated parameters to local properties. **This helps to reduce:** - The time spent setting up and tearing down a test for each unique parameter value combination. - The time spent starting and stopping NetworkManagers. - The total number of tests is more than cut in half. - _There is a known limitation with 2021 & 2022 TestRunner where reaching/exceed the 8-10k total tests count range can start to impact performance._ ## Changelog NA ## Testing and Documentation - Includes some `UniversalRpcTests` refactoring. - Includes new `UniversalRpcGroupedTests`. - Includes commenting out all legacy tests that were migrated into `UniversalRpcGroupedTests`. <!-- Uncomment and mark items off with a * if this PR deprecates any API: ### Deprecated API - [ ] An `[Obsolete]` attribute was added along with a `(RemovedAfter yyyy-mm-dd)` entry. - [ ] An [api updater] was added. - [ ] Deprecation of the API is explained in the CHANGELOG. - [ ] The users can understand why this API was removed and what they should use instead. --> ## Backport This most likely could be up-ported to v2.x, but for the time being this should be reviewed merged for the v1.14.0 release. <!-- If this is a backport: - Add the following to the PR title: "\[Backport\] ..." . - Link to the original PR. If this needs a backport - state this here If a backport is not needed please provide the reason why. If the "Backports" section is not present it will lead to a CI test failure. -->
1 parent 268e480 commit 89a825f

File tree

4 files changed

+620
-91
lines changed

4 files changed

+620
-91
lines changed

com.unity.netcode.gameobjects/Tests/Editor/Messaging/MessageCorruptionTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ public unsafe void Send(ulong clientId, NetworkDelivery delivery, FastBufferWrit
9595
for (int i = 0; i < 4; i++)
9696
{
9797
var currentByte = batchData.GetUnsafePtr()[i];
98-
batchData.WriteByteSafe((byte)(currentByte == 0 ? 1 : 0));
98+
currentByte = (byte)((currentByte + 1) % 255);
99+
batchData.WriteByteSafe(currentByte);
99100
MessageQueue.Add(batchData.ToArray());
100101
}
101102
break;

com.unity.netcode.gameobjects/Tests/Runtime/Transports/UnityTransportTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public IEnumerator Cleanup()
4343

4444
// Need to destroy the GameObject (all assigned components will get destroyed too)
4545
UnityEngine.Object.DestroyImmediate(m_Server.gameObject);
46+
m_Server = null;
4647
}
4748

4849
if (m_Client1)
@@ -51,6 +52,7 @@ public IEnumerator Cleanup()
5152

5253
// Need to destroy the GameObject (all assigned components will get destroyed too)
5354
UnityEngine.Object.DestroyImmediate(m_Client1.gameObject);
55+
m_Client1 = null;
5456
}
5557

5658
if (m_Client2)
@@ -59,6 +61,7 @@ public IEnumerator Cleanup()
5961

6062
// Need to destroy the GameObject (all assigned components will get destroyed too)
6163
UnityEngine.Object.DestroyImmediate(m_Client2.gameObject);
64+
m_Client2 = null;
6265
}
6366

6467
m_ServerEvents?.Clear();
@@ -315,7 +318,7 @@ public IEnumerator DisconnectOnReliableSendQueueOverflow()
315318
m_Server.StartServer();
316319
m_Client1.StartClient();
317320

318-
yield return WaitForNetworkEvent(NetworkEvent.Connect, m_Client1Events);
321+
yield return WaitForNetworkEvent(NetworkEvent.Connect, m_Client1Events, 5.0f);
319322

320323
m_Server.Shutdown();
321324

0 commit comments

Comments
 (0)