From 320cd383b566dd0763dd2a5c4bb7b9c20ce9fa15 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 5 Mar 2025 14:04:09 -0500 Subject: [PATCH 01/17] chore: Update the port of the codec tests --- .../DistributedAuthority/DistributedAuthorityCodecTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs b/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs index 398d0403ee..4f25d960eb 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs @@ -30,7 +30,7 @@ internal class DistributedAuthorityCodecTests : NetcodeIntegrationTest private NetworkManager Client => m_ClientNetworkManagers[0]; private string m_TransportHost = Environment.GetEnvironmentVariable("NGO_HOST") ?? "127.0.0.1"; - private const int k_TransportPort = 7777; + private const int k_TransportPort = 7788; private const int k_ClientId = 0; private GameObject m_SpawnObject; From a1208787fa0a285ac5d28a392139535535966214 Mon Sep 17 00:00:00 2001 From: Emma Date: Thu, 6 Mar 2025 13:54:42 -0500 Subject: [PATCH 02/17] Make port configurable --- .../DistributedAuthorityCodecTests.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs b/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs index 4f25d960eb..603b080a42 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs @@ -30,9 +30,15 @@ internal class DistributedAuthorityCodecTests : NetcodeIntegrationTest private NetworkManager Client => m_ClientNetworkManagers[0]; private string m_TransportHost = Environment.GetEnvironmentVariable("NGO_HOST") ?? "127.0.0.1"; - private const int k_TransportPort = 7788; + private static readonly ushort k_TransportPort = GetPortToBind(7777); private const int k_ClientId = 0; + private static ushort GetPortToBind(ushort defaultPort) + { + var value = Environment.GetEnvironmentVariable("ECHO_SERVER_PORT"); + return ushort.TryParse(value, out var configuredPort) ? configuredPort : defaultPort; + } + private GameObject m_SpawnObject; internal class TestNetworkComponent : NetworkBehaviour From 58c9cfdce0376320f896812a6679f5c3ac01e38e Mon Sep 17 00:00:00 2001 From: Emma Date: Thu, 6 Mar 2025 14:11:34 -0500 Subject: [PATCH 03/17] Add code docs --- .../DistributedAuthorityCodecTests.cs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs b/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs index 603b080a42..f4ee321a86 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs @@ -16,6 +16,18 @@ namespace Unity.Netcode.RuntimeTests { + /// + /// This class tests the NGO message codec between the C# SDK and the Rust runtime. + /// + /// + /// These tests are run against a rust echo-server. + /// This server decodes incoming messages, and then re-encodes them before sending them back to the client. + /// Any errors in decoding or encoding messages will not echo the messages back, causing the tests to fail + /// No message handling logic is tested in these tests. They are only testing the codec. + /// The tests check if they can bind to a rust echo-server at the given address and port, if all tests are ignored. + /// The rust echo-server is run using `cargo run --example ngo_echo_server -- --port {port}` + /// The C# port can be configured using the environment variable "ECHO_SERVER_PORT" + /// internal class DistributedAuthorityCodecTests : NetcodeIntegrationTest { protected override int NumberOfClients => 1; @@ -30,13 +42,17 @@ internal class DistributedAuthorityCodecTests : NetcodeIntegrationTest private NetworkManager Client => m_ClientNetworkManagers[0]; private string m_TransportHost = Environment.GetEnvironmentVariable("NGO_HOST") ?? "127.0.0.1"; - private static readonly ushort k_TransportPort = GetPortToBind(7777); + private static readonly ushort k_TransportPort = GetPortToBind(); private const int k_ClientId = 0; - private static ushort GetPortToBind(ushort defaultPort) + /// + /// Configures the port to look for the rust echo-server. + /// + /// The port from the environment variable "ECHO_SERVER_PORT" if it is set and valid; otherwise uses port 7777 + private static ushort GetPortToBind() { var value = Environment.GetEnvironmentVariable("ECHO_SERVER_PORT"); - return ushort.TryParse(value, out var configuredPort) ? configuredPort : defaultPort; + return ushort.TryParse(value, out var configuredPort) ? configuredPort : (ushort)7777; } private GameObject m_SpawnObject; From 756c348f91c8a48a9e9382026434f94e5b59863c Mon Sep 17 00:00:00 2001 From: Emma Date: Tue, 4 Mar 2025 15:19:26 -0500 Subject: [PATCH 04/17] feat: run DistributedAuthorityCodecTests in yamato --- .yamato/desktop-standalone-tests.yml | 34 ++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/.yamato/desktop-standalone-tests.yml b/.yamato/desktop-standalone-tests.yml index b12c71f2eb..b6cd13ffb8 100644 --- a/.yamato/desktop-standalone-tests.yml +++ b/.yamato/desktop-standalone-tests.yml @@ -7,7 +7,7 @@ # Builds are made on each supported editor as in project.metafile declaration # Builds are made with different scripting backends as in project.metafile declaration # ARM64 architectures are for now not considered since Windows_arm64 is recommended to use only after builds (would require separation here) and when it comes to macOS_arm64 there is problem with OpenCL not being available - + # Build phase {% for project in projects.default -%} {% for platform in test_platforms.desktop -%} @@ -24,9 +24,10 @@ desktop_standalone_build_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{ {% if platform.name == "ubuntu" %} - sudo apt-get update -q - sudo apt install -qy imagemagick + {% endif %} - pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple - + # Platform specific UTR setup - | {% if platform.name == "win" %} @@ -34,10 +35,10 @@ desktop_standalone_build_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{ {% else %} curl -s https://artifactory.prd.it.unity3d.com/artifactory/unity-tools-local/utr-standalone/utr --output utr && chmod +x utr {% endif %} - + # Installing editor - unity-downloader-cli -u {{ editor }} -c Editor {% if backend == "il2cpp" %} -c il2cpp {% endif %} --fast --wait - + # Build Player - | {% if platform.name == "win" %} @@ -53,17 +54,17 @@ desktop_standalone_build_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{ logs: paths: - "artifacts/**/*" - + dependencies: - .yamato/project-pack.yml#project_pack_-_{{ project.name }}_{{ platform.name }} {% endfor -%} {% endfor -%} {% endfor -%} {% endfor -%} - - - - + + + + # Run phase {% for project in projects.default -%} {% for platform in test_platforms.desktop -%} @@ -86,7 +87,20 @@ desktop_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{ - pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple - unity-downloader-cli -u {{ editor }} -c Editor {% if backend == "il2cpp" %} -c il2cpp {% endif %} --fast --wait - + +# If ubuntu, run rust echo server +{% if platform.name == "ubuntu" %} + - git clone https://github.com/Unity-Technologies/mps-common-multiplayer-backend.git + - pushd mps-common-multiplayer-backend/runtime + # Install rust + - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + # Build the echo server + - cargo build --example ngo_echo_server + # Run the echo server in the background - this will reuse the artifacts from the build + - cargo run --example ngo_echo_server & + - popd +{% endif %} + # Run Standalone tests - | {% if platform.name == "win" %} From cab40af548634e82d6df9791353fa38abea6f8aa Mon Sep 17 00:00:00 2001 From: Emma Date: Tue, 4 Mar 2025 15:51:37 -0500 Subject: [PATCH 05/17] silently install rustup --- .yamato/desktop-standalone-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.yamato/desktop-standalone-tests.yml b/.yamato/desktop-standalone-tests.yml index b6cd13ffb8..e7e9c3b472 100644 --- a/.yamato/desktop-standalone-tests.yml +++ b/.yamato/desktop-standalone-tests.yml @@ -93,7 +93,7 @@ desktop_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{ - git clone https://github.com/Unity-Technologies/mps-common-multiplayer-backend.git - pushd mps-common-multiplayer-backend/runtime # Install rust - - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y # Build the echo server - cargo build --example ngo_echo_server # Run the echo server in the background - this will reuse the artifacts from the build From 6c8cf14f830848b1c3e67513d2cf23e80895c11a Mon Sep 17 00:00:00 2001 From: Emma Date: Tue, 4 Mar 2025 16:20:57 -0500 Subject: [PATCH 06/17] Use cargo bin command --- .yamato/desktop-standalone-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.yamato/desktop-standalone-tests.yml b/.yamato/desktop-standalone-tests.yml index e7e9c3b472..22e576faf2 100644 --- a/.yamato/desktop-standalone-tests.yml +++ b/.yamato/desktop-standalone-tests.yml @@ -95,9 +95,9 @@ desktop_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{ # Install rust - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y # Build the echo server - - cargo build --example ngo_echo_server + - $HOME/.cargo/bin/cargo build --example ngo_echo_server # Run the echo server in the background - this will reuse the artifacts from the build - - cargo run --example ngo_echo_server & + - $HOME/.cargo/bin/cargo run --example ngo_echo_server & - popd {% endif %} From bfa958fdd5c6f0835ccf8400bd64d2852a118abd Mon Sep 17 00:00:00 2001 From: Emma Date: Tue, 4 Mar 2025 17:36:55 -0500 Subject: [PATCH 07/17] cd for each cargo command --- .yamato/desktop-standalone-tests.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.yamato/desktop-standalone-tests.yml b/.yamato/desktop-standalone-tests.yml index 22e576faf2..60afa890bc 100644 --- a/.yamato/desktop-standalone-tests.yml +++ b/.yamato/desktop-standalone-tests.yml @@ -90,15 +90,14 @@ desktop_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{ # If ubuntu, run rust echo server {% if platform.name == "ubuntu" %} - - git clone https://github.com/Unity-Technologies/mps-common-multiplayer-backend.git - - pushd mps-common-multiplayer-backend/runtime + - | + git clone https://github.com/Unity-Technologies/mps-common-multiplayer-backend.git # Install rust - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y # Build the echo server - - $HOME/.cargo/bin/cargo build --example ngo_echo_server + - cd ./mps-common-multiplayer-backend && $HOME/.cargo/bin/cargo build --example ngo_echo_server # Run the echo server in the background - this will reuse the artifacts from the build - - $HOME/.cargo/bin/cargo run --example ngo_echo_server & - - popd + - cd ./mps-common-multiplayer-backend && $HOME/.cargo/bin/cargo run --example ngo_echo_server & {% endif %} # Run Standalone tests From 35ece3977963677b94e9ea89042f4f44f134c1b6 Mon Sep 17 00:00:00 2001 From: Emma Date: Tue, 4 Mar 2025 18:36:06 -0500 Subject: [PATCH 08/17] Use actual directory path --- .yamato/desktop-standalone-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.yamato/desktop-standalone-tests.yml b/.yamato/desktop-standalone-tests.yml index 60afa890bc..b84368a7a4 100644 --- a/.yamato/desktop-standalone-tests.yml +++ b/.yamato/desktop-standalone-tests.yml @@ -95,9 +95,9 @@ desktop_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{ # Install rust - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y # Build the echo server - - cd ./mps-common-multiplayer-backend && $HOME/.cargo/bin/cargo build --example ngo_echo_server + - cd ./mps-common-multiplayer-backend/runtime && $HOME/.cargo/bin/cargo build --example ngo_echo_server # Run the echo server in the background - this will reuse the artifacts from the build - - cd ./mps-common-multiplayer-backend && $HOME/.cargo/bin/cargo run --example ngo_echo_server & + - cd ./mps-common-multiplayer-backend/runtime && $HOME/.cargo/bin/cargo run --example ngo_echo_server & {% endif %} # Run Standalone tests From 51c4e939477685e909939d9be3d8e874e1f43fa8 Mon Sep 17 00:00:00 2001 From: Emma Date: Thu, 6 Mar 2025 16:58:00 -0500 Subject: [PATCH 09/17] Configure echo-server port --- .yamato/desktop-standalone-tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.yamato/desktop-standalone-tests.yml b/.yamato/desktop-standalone-tests.yml index b84368a7a4..40382f5227 100644 --- a/.yamato/desktop-standalone-tests.yml +++ b/.yamato/desktop-standalone-tests.yml @@ -76,6 +76,8 @@ desktop_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{ type: {% if platform.name == "mac" %} {{ platform.type }} {% else %} {{ platform.type }}::GPU {% endif %} image: {{ platform.image }} flavor: {{ platform.flavor }} + variables: + ECHO_SERVER_PORT: "7788" commands: # Platform specific UTR setup - | @@ -97,7 +99,7 @@ desktop_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{ # Build the echo server - cd ./mps-common-multiplayer-backend/runtime && $HOME/.cargo/bin/cargo build --example ngo_echo_server # Run the echo server in the background - this will reuse the artifacts from the build - - cd ./mps-common-multiplayer-backend/runtime && $HOME/.cargo/bin/cargo run --example ngo_echo_server & + - cd ./mps-common-multiplayer-backend/runtime && $HOME/.cargo/bin/cargo run --example ngo_echo_server -- --port $ECHO_SERVER_PORT & {% endif %} # Run Standalone tests From 4c2ec29700f307c42ad607d40f602313a8d73ba2 Mon Sep 17 00:00:00 2001 From: Emma Date: Thu, 6 Mar 2025 17:00:33 -0500 Subject: [PATCH 10/17] Add more explicit ignore message --- .../DistributedAuthority/DistributedAuthorityCodecTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs b/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs index f4ee321a86..f404d24cd6 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs @@ -76,7 +76,7 @@ protected override void OnOneTimeSetup() #else if (!CanConnectToServer(m_TransportHost, k_TransportPort)) { - Assert.Ignore("ignoring DA codec tests because UTP transport cannot connect to the runtime"); + Assert.Ignore($"ignoring DA codec tests because UTP transport cannot connect to the rust echo-server at ${m_TransportHost}:{k_TransportPort}"); } #endif base.OnOneTimeSetup(); From 35c6d0aff600475d9b35239b3ec71a2748614430 Mon Sep 17 00:00:00 2001 From: Emma Date: Thu, 6 Mar 2025 18:32:21 -0500 Subject: [PATCH 11/17] Add ENSURE_CODEC_TESTS environment variable --- .yamato/desktop-standalone-tests.yml | 10 +++++++--- .../DistributedAuthorityCodecTests.cs | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.yamato/desktop-standalone-tests.yml b/.yamato/desktop-standalone-tests.yml index 40382f5227..d038aea5ca 100644 --- a/.yamato/desktop-standalone-tests.yml +++ b/.yamato/desktop-standalone-tests.yml @@ -77,7 +77,12 @@ desktop_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{ image: {{ platform.image }} flavor: {{ platform.flavor }} variables: +{% if platform.name != "win" %} ECHO_SERVER_PORT: "7788" + # Ensure the DA codec tests will fail if they cannot connect to the echo-server + # The default is to ignore the codec tests if the echo-server fails to connect + ENSURE_CODEC_TESTS: "true" +{% endif %} commands: # Platform specific UTR setup - | @@ -91,9 +96,8 @@ desktop_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{ - unity-downloader-cli -u {{ editor }} -c Editor {% if backend == "il2cpp" %} -c il2cpp {% endif %} --fast --wait # If ubuntu, run rust echo server -{% if platform.name == "ubuntu" %} - - | - git clone https://github.com/Unity-Technologies/mps-common-multiplayer-backend.git +{% if platform.name != "win" %} + - git clone https://github.com/Unity-Technologies/mps-common-multiplayer-backend.git # Install rust - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y # Build the echo server diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs b/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs index f404d24cd6..1f495de98e 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs @@ -27,6 +27,8 @@ namespace Unity.Netcode.RuntimeTests /// The tests check if they can bind to a rust echo-server at the given address and port, if all tests are ignored. /// The rust echo-server is run using `cargo run --example ngo_echo_server -- --port {port}` /// The C# port can be configured using the environment variable "ECHO_SERVER_PORT" + /// The default behaviour when unity fails to connect to the echo-server is to ignore all tests in this class. + /// This can be overridden by setting the environment variable "ENSURE_CODEC_TESTS" to any value - then the tests will fail. /// internal class DistributedAuthorityCodecTests : NetcodeIntegrationTest { @@ -60,7 +62,7 @@ private static ushort GetPortToBind() internal class TestNetworkComponent : NetworkBehaviour { public NetworkList MyNetworkList = new NetworkList(new List { 1, 2, 3 }); - public NetworkVariable MyNetworkVar = new NetworkVariable(3); + public NetworkVariable myNetworkVar = new NetworkVariable(3); [Rpc(SendTo.Authority)] public void TestAuthorityRpc(byte[] _) @@ -76,7 +78,15 @@ protected override void OnOneTimeSetup() #else if (!CanConnectToServer(m_TransportHost, k_TransportPort)) { - Assert.Ignore($"ignoring DA codec tests because UTP transport cannot connect to the rust echo-server at ${m_TransportHost}:{k_TransportPort}"); + var shouldFail = Environment.GetEnvironmentVariable("ENSURE_CODEC_TESTS"); + if (!string.IsNullOrEmpty(shouldFail)) + { + Assert.Fail($"Failed to connect to the rust echo-server at {m_TransportHost}:{k_TransportPort}"); + } + else + { + Assert.Ignore($"ignoring DA codec tests because UTP transport cannot connect to the rust echo-server at {m_TransportHost}:{k_TransportPort}"); + } } #endif base.OnOneTimeSetup(); @@ -250,9 +260,9 @@ public IEnumerator NetworkVariableDelta_WithValueUpdate() var component = instance.GetComponent(); var newValue = 5; - component.MyNetworkVar.Value = newValue; + component.myNetworkVar.Value = newValue; yield return m_ClientCodecHook.WaitForMessageReceived(); - Assert.AreEqual(newValue, component.MyNetworkVar.Value); + Assert.AreEqual(newValue, component.myNetworkVar.Value); } [UnityTest] From 43000e572caea380dce67ab8be5fb2e26768eceb Mon Sep 17 00:00:00 2001 From: Emma Date: Thu, 6 Mar 2025 18:56:19 -0500 Subject: [PATCH 12/17] Change env variable define --- .yamato/desktop-standalone-tests.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.yamato/desktop-standalone-tests.yml b/.yamato/desktop-standalone-tests.yml index d038aea5ca..c6f13a555b 100644 --- a/.yamato/desktop-standalone-tests.yml +++ b/.yamato/desktop-standalone-tests.yml @@ -77,12 +77,11 @@ desktop_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{ image: {{ platform.image }} flavor: {{ platform.flavor }} variables: -{% if platform.name != "win" %} ECHO_SERVER_PORT: "7788" # Ensure the DA codec tests will fail if they cannot connect to the echo-server # The default is to ignore the codec tests if the echo-server fails to connect - ENSURE_CODEC_TESTS: "true" -{% endif %} + ENSURE_CODEC_TESTS: {% if platform.name != "win" %} "true" {% endif %} + commands: # Platform specific UTR setup - | From 6ba21ccc0005426636c76310ae5c179822064517 Mon Sep 17 00:00:00 2001 From: Emma Date: Thu, 6 Mar 2025 18:57:03 -0500 Subject: [PATCH 13/17] Remove ensure environment variable --- .yamato/desktop-standalone-tests.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.yamato/desktop-standalone-tests.yml b/.yamato/desktop-standalone-tests.yml index c6f13a555b..459ebb70c8 100644 --- a/.yamato/desktop-standalone-tests.yml +++ b/.yamato/desktop-standalone-tests.yml @@ -78,9 +78,6 @@ desktop_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{ flavor: {{ platform.flavor }} variables: ECHO_SERVER_PORT: "7788" - # Ensure the DA codec tests will fail if they cannot connect to the echo-server - # The default is to ignore the codec tests if the echo-server fails to connect - ENSURE_CODEC_TESTS: {% if platform.name != "win" %} "true" {% endif %} commands: # Platform specific UTR setup From 04d47514b316c8634d8a91896a0d7a68f3758e02 Mon Sep 17 00:00:00 2001 From: Emma Date: Thu, 6 Mar 2025 18:58:05 -0500 Subject: [PATCH 14/17] Re-add ensure with else value --- .yamato/desktop-standalone-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.yamato/desktop-standalone-tests.yml b/.yamato/desktop-standalone-tests.yml index 459ebb70c8..85fbb8eff5 100644 --- a/.yamato/desktop-standalone-tests.yml +++ b/.yamato/desktop-standalone-tests.yml @@ -78,6 +78,9 @@ desktop_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{ flavor: {{ platform.flavor }} variables: ECHO_SERVER_PORT: "7788" + # Ensure the DA codec tests will fail if they cannot connect to the echo-server + # The default is to ignore the codec tests if the echo-server fails to connect + ENSURE_CODEC_TESTS: {% if platform.name != "win" %} "true" {% else %} "" {% endif %} commands: # Platform specific UTR setup From 664c1d8516835943d92f28265e75384fcf4b021a Mon Sep 17 00:00:00 2001 From: Emma Date: Thu, 6 Mar 2025 19:19:03 -0500 Subject: [PATCH 15/17] Ensure no empty space in job setup --- .yamato/desktop-standalone-tests.yml | 8 ++++++-- .../DistributedAuthorityCodecTests.cs | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.yamato/desktop-standalone-tests.yml b/.yamato/desktop-standalone-tests.yml index 85fbb8eff5..bdacea3d49 100644 --- a/.yamato/desktop-standalone-tests.yml +++ b/.yamato/desktop-standalone-tests.yml @@ -76,11 +76,15 @@ desktop_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{ type: {% if platform.name == "mac" %} {{ platform.type }} {% else %} {{ platform.type }}::GPU {% endif %} image: {{ platform.image }} flavor: {{ platform.flavor }} + +# Set additional variables for running the echo server +{% if platform.name != "win" %} variables: ECHO_SERVER_PORT: "7788" - # Ensure the DA codec tests will fail if they cannot connect to the echo-server + # Set this to ensure the DA codec tests will fail if they cannot connect to the echo-server # The default is to ignore the codec tests if the echo-server fails to connect - ENSURE_CODEC_TESTS: {% if platform.name != "win" %} "true" {% else %} "" {% endif %} + ENSURE_CODEC_TESTS: "true" +{% endif %} commands: # Platform specific UTR setup diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs b/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs index 1f495de98e..09c7523302 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs @@ -79,13 +79,13 @@ protected override void OnOneTimeSetup() if (!CanConnectToServer(m_TransportHost, k_TransportPort)) { var shouldFail = Environment.GetEnvironmentVariable("ENSURE_CODEC_TESTS"); - if (!string.IsNullOrEmpty(shouldFail)) + if (string.IsNullOrEmpty(shouldFail) || shouldFail.ToLower == "false") { - Assert.Fail($"Failed to connect to the rust echo-server at {m_TransportHost}:{k_TransportPort}"); + Assert.Ignore($"ignoring DA codec tests because UTP transport cannot connect to the rust echo-server at {m_TransportHost}:{k_TransportPort}"); } else { - Assert.Ignore($"ignoring DA codec tests because UTP transport cannot connect to the rust echo-server at {m_TransportHost}:{k_TransportPort}"); + Assert.Fail($"Failed to connect to the rust echo-server at {m_TransportHost}:{k_TransportPort}"); } } #endif From 55591ea312e1d43a37093277e2966c3bdd89d778 Mon Sep 17 00:00:00 2001 From: Emma Date: Fri, 7 Mar 2025 10:01:04 -0500 Subject: [PATCH 16/17] Use ToLower properly --- .../DistributedAuthority/DistributedAuthorityCodecTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs b/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs index 09c7523302..8918036df8 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs @@ -79,7 +79,7 @@ protected override void OnOneTimeSetup() if (!CanConnectToServer(m_TransportHost, k_TransportPort)) { var shouldFail = Environment.GetEnvironmentVariable("ENSURE_CODEC_TESTS"); - if (string.IsNullOrEmpty(shouldFail) || shouldFail.ToLower == "false") + if (string.IsNullOrEmpty(shouldFail) || shouldFail.ToLower() == "false") { Assert.Ignore($"ignoring DA codec tests because UTP transport cannot connect to the rust echo-server at {m_TransportHost}:{k_TransportPort}"); } From 4d11fefd5a526778937772f982d8f38fbbab2cab Mon Sep 17 00:00:00 2001 From: Emma Date: Fri, 7 Mar 2025 11:25:44 -0500 Subject: [PATCH 17/17] Fix variable casing --- .../DistributedAuthority/DistributedAuthorityCodecTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs b/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs index 8918036df8..2947b5830f 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs @@ -62,7 +62,7 @@ private static ushort GetPortToBind() internal class TestNetworkComponent : NetworkBehaviour { public NetworkList MyNetworkList = new NetworkList(new List { 1, 2, 3 }); - public NetworkVariable myNetworkVar = new NetworkVariable(3); + public NetworkVariable MyNetworkVar = new NetworkVariable(3); [Rpc(SendTo.Authority)] public void TestAuthorityRpc(byte[] _) @@ -260,9 +260,9 @@ public IEnumerator NetworkVariableDelta_WithValueUpdate() var component = instance.GetComponent(); var newValue = 5; - component.myNetworkVar.Value = newValue; + component.MyNetworkVar.Value = newValue; yield return m_ClientCodecHook.WaitForMessageReceived(); - Assert.AreEqual(newValue, component.myNetworkVar.Value); + Assert.AreEqual(newValue, component.MyNetworkVar.Value); } [UnityTest]