Skip to content

Commit 50a6772

Browse files
chore: gate unified tests in C# via UNIFIED_TESTS instead of a YAML test filter
Unified selection now lives in C# instead: - unified-tests.yml sets UNIFIED_TESTS=true and passes no --testfilter; unified_test_filter is removed from project.metafile. - NetcodeIntegrationTest.UseUnifiedTests() (virtual, defaults to false) is the opt-in a fixture overrides to run in a unified pass. USE_CMB_SERVICE still takes precedence. - Adds IgnoreIfUnifiedTestsEnvironmentVariableSetAttribute and the matching NetcodeIntegrationTestHelpers.IgnoreIfUnifiedTestsEnvironmentVariableSet() so fixtures that do not apply under unified netcode opt out explicitly. - Applies that opt-out across the package and testproject fixtures that do not need to run against hybrid prefabs.
1 parent aec318d commit 50a6772

34 files changed

Lines changed: 285 additions & 63 deletions

.yamato/project.metafile

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -219,25 +219,6 @@ unified_test_platforms:
219219
image: package-ci/ubuntu-22.04:v4.87.0
220220
flavor: b1.large
221221

222-
# Restricts the unified job to unified-only tests so nothing else runs on the alpha editor.
223-
#
224-
# This is a REGULAR EXPRESSION, not a glob. UTR passes it to the editor as -testFilter, which ends up
225-
# in UnityEngine.TestRunner's FullNameFilter -> NUnit ValueMatchFilter -> new Regex(pattern).IsMatch().
226-
# A glob-style "*Unified*" throws "Quantifier {x,y} following nothing" and fails the whole run.
227-
# The other jobs' "Unity.Netcode.RuntimeTests.*" works because it is also a valid regex - it just
228-
# happens to read like a glob.
229-
#
230-
# The match is against the NUnit *full* test name, which includes both fixture and method arguments.
231-
#
232-
# DO NOT widen this to ".*Unified.*". "Unified" appearing in a test name does NOT mean that test was
233-
# deliberately converted to run against hybrid prefabs. HostOrServer gained UnifiedServer/UnifiedHost
234-
# members under UNIFIED_NETCODE, and NUnit expands a bare [Values] on an enum parameter (and
235-
# enum-typed fixture constructors) to every member. So with N4E installed, much of the existing suite
236-
# silently grows unified cases - e.g. NetworkVariableTests(Default).AllNetworkVariableTypes(UnifiedHost),
237-
# which nobody wrote. ".*Unified.*" selected 138 tests, 84 of which failed, against the 1 test this
238-
# job exists to validate. Deciding which of those should pass, and how they opt in, is Goal-2.
239-
unified_test_filter: ".*UnifiedNetworkTransformTest.*"
240-
241222

242223
# Scripting backends used by Standalone RunTimeTests---------------------------------------------------
243224

.yamato/unified-tests.yml

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,17 @@
22
---
33

44
# DESCRIPTION--------------------------------------------------------------------------
5-
# This job validates NGO running against Netcode for Entities (N4E) through the unified API.
6-
# A "hybrid prefab" is an NGO prefab (NetworkObject at the root) that also carries a GhostObject.
7-
# When one or more hybrid prefabs are in the NetworkManager's prefab list, NGO hands transform
8-
# synchronization to N4E's snapshot system and tunnels its own batched messages over
9-
# UnifiedNetcodeTransport (N4E's out-of-band RPC) instead of using a NetworkTransport such as UTP.
10-
# UnifiedNetworkTransformTest is the validation test that this path works end to end.
11-
12-
# WHY THIS JOB IS SEPARATE FROM EVERY OTHER JOB------------------------------------------
13-
# 1. It needs an editor that bundles a com.unity.netcode with the unified API. That editor
14-
# (unified_editors.default in project.metafile) is not one of the validation_editors, and NGO
15-
# still has to keep building and testing against editors that have no unified API at all.
16-
# 2. It needs com.unity.netcode in the testproject so that the UNIFIED_NETCODE define is set
17-
# (see the versionDefines in Unity.Netcode.Runtime.asmdef). The committed
18-
# testproject/Packages/manifest.json deliberately does NOT reference it, so this job swaps in
19-
# testproject/Packages/manifest-unified.json instead.
20-
# 3. It is wired into pr_code_changes_checks and develop_nightly the same way the CMB service tests
21-
# are, so it runs automatically on PRs targeting develop / develop-3.x.x / release. Be aware that
22-
# this makes an unsupported alpha editor part of the PR gate: when N4E lands breaking changes in
23-
# trunk this job goes red and the pin has to be bumped to unblock PRs.
24-
# _triggers.yml also has unified_pr_checks, so it can be kicked off with "/ci unified" on PRs
25-
# that pr_code_changes_checks does not cover.
5+
# The NGO job that runs unified netcode hybrid prefab based integration tests.
266

277
# CONFIGURATION STRUCTURE--------------------------------------------------------------
288
# Jobs are generated using nested loops:
299
# 1. For all unified test platforms (currently Ubuntu only, see project.metafile)
3010
# 2. For all unified editors (currently a single pinned alpha, see project.metafile)
3111

32-
# TECHNICAL CONSIDERATIONS---------------------------------------------------------------
33-
# This job runs in Editor context only (no player builds required), like project-tests.yml.
34-
# Only playmode is run: every unified test is an integration test and there are no unified EditMode tests.
35-
# The run is restricted to unified tests via unified_test_filter so that nothing else is exercised
36-
# on the alpha editor. Non-unified tests are covered by the regular jobs on the supported editors.
37-
# packages-lock.json is removed because the committed lock was resolved against a much older editor
38-
# and its builtin package versions do not exist in the unified editor.
39-
4012
# QUALITY CONSIDERATIONS--------------------------------------------------------------------
4113
# TODO: the manifest swap means testproject/Packages/manifest-unified.json has to be kept in sync
4214
# with manifest.json by hand. Revisit once N4E is a hard dependency of NGO and one manifest
4315
# can cover both cases.
44-
# TODO: unified_test_filter is a test-name pattern. Replacing it with an NUnit category (for
45-
# example [Category("Unified")]) would be less fragile once more fixtures gain unified variants.
4616

4717
#------------------------------------------------------------------------------------
4818

@@ -58,21 +28,28 @@ unified_test_{{ project.name }}_{{ platform.name }}_{{ editor }}:
5828
{% if platform.model %}
5929
model: {{ platform.model }} # This is set only in platforms where we want non-default model to use (more information in project.metafile)
6030
{% endif %}
31+
32+
variables:
33+
# When UNIFIED_TESTS is set, only integration tests that opt in via overriding NetcodeIntegrationTest.UseUnifiedTests and returning true will run during this job.
34+
# NetcodeIntegrationTest.UseUnifiedTests defaults to returning false (for now) making this an opt-in mode.
35+
# Note: If USE_CMB_SERVICE is set along with UNIFIED_TESTS, then UNIFIED_TESTS is ignored until distributed authority is supported.
36+
UNIFIED_TESTS: "true"
37+
6138
commands:
62-
# Swap in the manifest that pulls in com.unity.netcode (N4E). This is what causes UNIFIED_NETCODE
63-
# to be defined and therefore what makes the unified tests compile at all.
39+
# Swap in the manifest that has the unified packages and versions required.
40+
# Without the N4E package, UNIFIED_NETCODE is undefined and the unified API excluded.
6441
- cp {{ project.path }}/Packages/manifest-unified.json {{ project.path }}/Packages/manifest.json
65-
# The committed lock was resolved against a supported editor, not the unified alpha.
42+
# Remove the committed lock as it is configured for 6000.6 which does not contain the unified API required.
6643
- rm -f {{ project.path }}/Packages/packages-lock.json
6744

68-
- unity-downloader-cli --fast --wait -u {{ editor }} -c Editor # Installing basic editor for tests execution
69-
- UnifiedTestRunner --testproject={{ project.path }} --suite=playmode --artifacts-path=test-results --editor-location=.Editor --testfilter="{{ unified_test_filter }}" --rerun-strategy=Test --retry={{ num_test_retries }} --clean-library-on-rerun --timeout={{ test_timeout }}
45+
- unity-downloader-cli --fast --wait -u {{ editor }} -c Editor
46+
- UnifiedTestRunner --testproject={{ project.path }} --suite=playmode --artifacts-path=test-results --editor-location=.Editor --rerun-strategy=Test --retry={{ num_test_retries }} --clean-library-on-rerun --timeout={{ test_timeout }}
7047
artifacts:
7148
logs:
7249
paths:
7350
- "test-results/**/*"
7451
dependencies:
75-
- .yamato/_run-all.yml#run_quick_checks # initial checks to perform fast validation of common errors
52+
- .yamato/_run-all.yml#run_quick_checks
7653
{% endfor -%}
7754
{% endfor -%}
7855
{% endfor -%}

com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,12 +1412,12 @@ private bool UnifiedIsConfiguredCorrectly()
14121412
{
14131413
if (NetCodeConfig.Global == null)
14141414
{
1415-
Log.Error(new Context(LogLevel.Error, "You must create a {nameof(NetCodeConfig)} and set it to a single world in order to run in hybrid mode!").AddTag("Unified"));
1415+
Log.Error(new Context(LogLevel.Error, $"You must create a {nameof(NetCodeConfig)} and set it to a single world in order to run in hybrid mode!").AddTag("Unified"));
14161416
return false;
14171417
}
14181418
if (NetCodeConfig.Global.HostWorldModeSelection != NetCodeConfig.HostWorldMode.SingleWorld)
14191419
{
1420-
Log.Error(new Context(LogLevel.Error, "You must configure {nameof(NetCodeConfig)} to only use a single world in order to run in hybrid mode!").AddTag("Unified"));
1420+
Log.Error(new Context(LogLevel.Error, $"You must configure {nameof(NetCodeConfig)} to only use a single world in order to run in hybrid mode!").AddTag("Unified"));
14211421
return false;
14221422
}
14231423
return true;

com.unity.netcode.gameobjects/Tests/Runtime/Connection/ClientOnlyConnectionTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public void OneTimeSetup()
2020
{
2121
// TODO: [CmbServiceTests] if this test is deemed needed to test against the CMB server then update this test.
2222
NetcodeIntegrationTestHelpers.IgnoreIfServiceEnviromentVariableSet();
23+
// Excluding from unified tests. If deemed needed, update test, then remove.
24+
NetcodeIntegrationTestHelpers.IgnoreIfUnifiedTestsEnvironmentVariableSet();
2325
}
2426

2527
[SetUp]

com.unity.netcode.gameobjects/Tests/Runtime/NestedNetworkManagerTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public void OneTimeSetup()
1515
{
1616
// TODO: [CmbServiceTests] if this test is deemed needed to test against the CMB server then update this test.
1717
NetcodeIntegrationTestHelpers.IgnoreIfServiceEnviromentVariableSet();
18+
// Excluding from unified tests. If deemed needed, update test, then remove.
19+
NetcodeIntegrationTestHelpers.IgnoreIfUnifiedTestsEnvironmentVariableSet();
1820
}
1921

2022
[Test]

com.unity.netcode.gameobjects/Tests/Runtime/NetworkManagerCustomMessageManagerTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public void OneTimeSetup()
1111
{
1212
// This test does not need to run against the Rust server.
1313
NetcodeIntegrationTestHelpers.IgnoreIfServiceEnviromentVariableSet();
14+
// Excluding from unified tests. If deemed needed, update test, then remove.
15+
NetcodeIntegrationTestHelpers.IgnoreIfUnifiedTestsEnvironmentVariableSet();
1416
}
1517

1618
[Test]

com.unity.netcode.gameobjects/Tests/Runtime/NetworkManagerEventsTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public void OneTimeSetup()
2222
{
2323
// TODO: [CmbServiceTests] if this test is deemed needed to test against the CMB server then update this test.
2424
NetcodeIntegrationTestHelpers.IgnoreIfServiceEnviromentVariableSet();
25+
// Excluding from unified tests. If deemed needed, update test, then remove.
26+
NetcodeIntegrationTestHelpers.IgnoreIfUnifiedTestsEnvironmentVariableSet();
2527
}
2628

2729
/// <summary>

com.unity.netcode.gameobjects/Tests/Runtime/NetworkManagerSceneManagerTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public void OneTimeSetup()
1111
{
1212
// This test does not need to run against the Rust server.
1313
NetcodeIntegrationTestHelpers.IgnoreIfServiceEnviromentVariableSet();
14+
// Excluding from unified tests. If deemed needed, update test, then remove.
15+
NetcodeIntegrationTestHelpers.IgnoreIfUnifiedTestsEnvironmentVariableSet();
1416
}
1517

1618
[Test]

com.unity.netcode.gameobjects/Tests/Runtime/NetworkManagerTransportTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public void OneTimeSetup()
1616
{
1717
// This test does not need to run against the Rust server.
1818
NetcodeIntegrationTestHelpers.IgnoreIfServiceEnviromentVariableSet();
19+
// Excluding from unified tests. If deemed needed, update test, then remove.
20+
NetcodeIntegrationTestHelpers.IgnoreIfUnifiedTestsEnvironmentVariableSet();
1921
}
2022

2123
[Test]

com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/NetworkTransformStateTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ namespace Unity.Netcode.RuntimeTests
1212
{
1313
// These tests do not need to run against the Rust server.
1414
[IgnoreIfServiceEnvironmentVariableSet]
15+
// These tests do not exercise hybrid prefabs.
16+
[IgnoreIfUnifiedTestsEnvironmentVariableSet]
1517
internal class NetworkTransformStateTests
1618
{
1719
[Test]
@@ -199,6 +201,8 @@ private void AssertTransformStateEquals(bool[] expected, NetworkTransformState a
199201

200202
// These tests do not need to run against the Rust server.
201203
[IgnoreIfServiceEnvironmentVariableSet]
204+
// These tests do not exercise hybrid prefabs.
205+
[IgnoreIfUnifiedTestsEnvironmentVariableSet]
202206
[TestFixture(TransformSpace.World, Precision.Full, Rotation.Euler)]
203207
[TestFixture(TransformSpace.World, Precision.Half, Rotation.Euler)]
204208
[TestFixture(TransformSpace.Local, Precision.Full, Rotation.Euler)]

0 commit comments

Comments
 (0)