Skip to content

Commit 33df318

Browse files
authored
chore: Pass the unity version to the CMB service (#3811)
* chore: Pass the unity version to the CMB service * Swap a test to a CMB test for validation * Fix standards check * Fix broken tests * Update yamato jobs * Make code change and trigger checks * Add to minimal checks * Actually add script changes * put yamato changes back * Put the build jobs on a larger VM * fix cmb script * Update bash commands to be proper * Fix bash else * try multiple * Lets go * Move tests back to trunk * Add unity version to codec tests
1 parent 1abb9a6 commit 33df318

File tree

10 files changed

+72
-48
lines changed

10 files changed

+72
-48
lines changed

.yamato/_triggers.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,8 @@ pr_code_changes_checks:
8787
# Coverage on other standalone machines is present in Nightly job so it's enough to not run all of them for PRs
8888
# desktop_standalone_test and cmb_service_standalone_test are both reusing desktop_standalone_build dependency so we run those in the same configuration on PRs to reduce waiting time.
8989
# Note that our daily tests will anyway run both test configurations in "minimal supported" and "trunk" configurations
90-
91-
# TODO: Move these tests back to trunk once CMB Service has addressed https://jira.unity3d.com/browse/MTTB-1680
92-
- .yamato/desktop-standalone-tests.yml#desktop_standalone_test_testproject_ubuntu_il2cpp_6000.4
93-
- .yamato/cmb-service-standalone-tests.yml#cmb_service_standalone_test_testproject_ubuntu_il2cpp_6000.4
90+
- .yamato/desktop-standalone-tests.yml#desktop_standalone_test_testproject_ubuntu_il2cpp_trunk
91+
- .yamato/cmb-service-standalone-tests.yml#cmb_service_standalone_test_testproject_ubuntu_il2cpp_trunk
9492
triggers:
9593
expression: |-
9694
(pull_request.comment eq "ngo" OR

.yamato/cmb-service-standalone-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ cmb_service_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}
5454

5555
commands:
5656
# run_cmb_service.sh builds and starts a release version of the full CMB service (along with the limited echo server)
57-
- ./Tools/CI/service.cmb/run_cmb_service.sh -e $ECHO_SERVER_PORT -s $CMB_SERVICE_PORT
57+
- ./Tools/CI/service.cmb/run_cmb_service.sh -e $ECHO_SERVER_PORT -s $CMB_SERVICE_PORT -l artifacts
5858

5959
- unity-downloader-cli --fast --wait -u {{ editor }} -c Editor {% if backend == "il2cpp" %} -c il2cpp {% endif %} {% if platform.name == "mac" %} --arch arm64 {% endif %} # For macOS we use ARM64 models
6060
- UnifiedTestRunner --suite=playmode --player-load-path=build/players --artifacts-path=test-results --testproject={{ project.path }} --editor-location=.Editor --playergraphicsapi=Null --fail-on-assert --rerun-strategy=Test --retry={{ num_test_retries }} --clean-library-on-rerun --timeout={{ test_timeout }}

.yamato/console-standalone-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ console_standalone_build_{{ project.name }}_{{ platform.name }}_{{ editor }}:
4545
agent:
4646
type: {{ platform.type }}
4747
image: {{ platform.image }}
48-
flavor: {{ platform.flavor }}
48+
flavor: {{ platform.larger_flavor }}
4949
{% if platform.model %}
5050
model: {{ platform.model }} # This is set only in platforms where we want non-default model to use (more information in project.metafile)
5151
{% endif %}

.yamato/desktop-standalone-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ desktop_standalone_build_{{ project.name }}_{{ platform.name }}_{{ backend }}_{{
3838
agent:
3939
type: {% if platform.name == "mac" %} {{ platform.type }} {% else %} {{ platform.type }} {% endif %}
4040
image: {{ platform.image }}
41-
flavor: {{ platform.flavor }}
41+
flavor: {{ platform.larger_flavor }}
4242
{% if platform.name == "mac" %}
4343
model: {{ platform.model }} # This is set only in platforms where we want non-default model to use (more information in project.metafile)
4444
{% endif %}

.yamato/mobile-standalone-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ mobile_standalone_build_{{ project.name }}_{{ platform.name }}_{{ editor }}:
4444
agent:
4545
type: {{ platform.type }}
4646
image: {{ platform.image }}
47-
flavor: {{ platform.flavor }}
47+
flavor: {{ platform.larger_flavor }}
4848
{% if platform.model %}
4949
model: {{ platform.model }} # This is set only in platforms where we want non-default model to use (more information in project.metafile)
5050
{% endif %}

.yamato/project.metafile

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# image --> Defines the package-ci Bokken image to use for the environment (e.g., package-ci/ubuntu-22.04:v4). This is basically a device configuration
1111
# flavor --> Determines the VM size/resources (e.g., b1.small, b1.large, m1.mac)
1212
# smaller_flavor --> An override for flavor that determines the VM size/resources for lighter weight jobs that can run on a smaller vm
13+
# larger_flavor --> An override for flavor that determines the VM size/resources for heavier weight jobs that can need a bigger vm
1314
# standalone --> Specifies the build target platform (e.g., StandaloneLinux64, Android, IOS)
1415
# model --> Defines specific hardware model requirements (e.g., rtx2080, iPhone model 13). Notice that trunk currently (19.08.2025) has 13.0 as minimal iOS version which devices below this are not supporting
1516
# base --> Indicates the base operating system for build operations (e.g., win, mac)
@@ -47,20 +48,24 @@ test_platforms:
4748
image: package-ci/ubuntu-22.04:v4.77.0
4849
flavor: b1.large
4950
smaller_flavor: b1.medium
51+
larger_flavor: b1.xlarge
5052
standalone: StandaloneLinux64
5153
model: rtx2080
5254
- name: win
5355
type: Unity::VM
5456
image: package-ci/win10:v4
5557
flavor: b1.large
5658
smaller_flavor: b1.medium
59+
larger_flavor: b1.xlarge
5760
standalone: StandaloneWindows64
5861
model: rtx2080
5962
- name: mac
6063
type: Unity::VM::osx
6164
image: package-ci/macos-13-arm64:v4 # ARM64 to support M1 model (below)
6265
flavor: m1.mac
63-
smaller_flavor: m1.mac # mac doesn't have a smaller vm size. We define it anyway as it simplifies the yaml templating to have it defined.
66+
# mac doesn't have a different vm sizes. We define it anyway as it simplifies the yaml templating to have it defined.
67+
smaller_flavor: m1.mac
68+
larger_flavor: m1.mac
6469
standalone: StandaloneOSX
6570
model: M1 # The default model (an x64 Intel Mac VM) quite often caused a known issue of doing all the bitflips in packages resulting in failures
6671
# For mobile devices there is a split between the build and run phase so there is a need of splitting specification for both
@@ -70,6 +75,7 @@ test_platforms:
7075
type: Unity::VM
7176
image: package-ci/win10:v4
7277
flavor: b1.large
78+
larger_flavor: b1.xlarge
7379
standalone: Android
7480
base: win
7581
architecture: armv7
@@ -86,13 +92,15 @@ test_platforms:
8692
type: Unity::mobile::shield
8793
image: package-ci/win10:v4
8894
flavor: b1.large
95+
larger_flavor: b1.xlarge
8996
standalone: Android
9097
base: win
9198
architecture: armv7
9299
- name: ios-arm64
93100
type: Unity::mobile::iPhone
94101
image: package-ci/macos-13-arm64:v4
95102
flavor: m1.mac
103+
larger_flavor: m1.mac
96104
model: 13
97105
standalone: IOS
98106
base: mac
@@ -102,53 +110,63 @@ test_platforms:
102110
type: Unity::VM
103111
image: package-ci/win10-ps4:v4
104112
flavor: b1.large
113+
larger_flavor: b1.xlarge
105114
standalone: PS4
106115
# - name: ps5 --> SEE MTT-12118
107116
# type: Unity::VM
108117
# image: package-ci/win10-ps5:v4
109118
# flavor: b1.large
119+
# larger_flavor: b1.xlarge
110120
# standalone: PS5
111121
- name: switch
112122
type: Unity::VM
113123
image: package-ci/win10-switch:v4
114124
flavor: b1.large
125+
larger_flavor: b1.xlarge
115126
standalone: Switch
116127
- name: GameCoreXboxOne
117128
type: Unity::VM
118129
image: package-ci/win10-xbox:v4
119130
flavor: b1.large
131+
larger_flavor: b1.xlarge
120132
standalone: GameCoreXboxOne
121133
- name: GameCoreScarlett
122134
type: Unity::VM
123135
image: package-ci/win10-xbox:v4
124136
flavor: b1.large
137+
larger_flavor: b1.xlarge
125138
standalone: GameCoreScarlett
126139
console_test:
127140
- name: ps4
128141
type: Unity::console::ps4
129142
image: package-ci/win10-ps4:v4
130143
flavor: b1.large
144+
larger_flavor: b1.xlarge
131145
standalone: PS4
132146
#- name: ps5 --> SEE MTT-12118
133147
# type: Unity::console::ps5
134148
# image: package-ci/win10-ps5:v4
135149
# flavor: b1.large
150+
# larger_flavor: b1.xlarge
136151
# standalone: PS5
137152
- name: switch
138153
type: Unity::console::switch
139154
image: package-ci/win10-switch:v4
140155
flavor: b1.large
156+
larger_flavor: b1.xlarge
141157
standalone: Switch
142158
base: win
143159
- name: GameCoreXboxOne
144160
type: Unity::console::xbox
145161
image: package-ci/win10-xbox:v4
146162
flavor: b1.large
163+
larger_flavor: b1.xlarge
147164
standalone: GameCoreXboxOne
148165
- name: GameCoreScarlett
149166
type: Unity::console::scarlett
150167
image: package-ci/win10-xbox:v4
151168
flavor: b1.large
169+
larger_flavor: b1.xlarge
152170
standalone: GameCoreScarlett
153171

154172
# EDITOR CONFIGURATIONS-------------------------------------------------------------------------------

Tools/CI/service.cmb/run_cmb_service.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ ERROR="Error: Expected ports to be defined! Example script usage:"
3838
EXAMPLE="run_cmb_service.sh -e <echo-server-port> -s <cmb-service-port>"
3939

4040
# get arguments passed to the script
41-
while getopts 'e:s:' flag; do
41+
while getopts 'e:s:l:' flag; do
4242
case "${flag}" in
4343
e) echo_port="${OPTARG}" ;;
4444
s) service_port="${OPTARG}" ;;
45+
l) build_logs="${OPTARG}" ;;
4546
*) printf "%s\n" "$ERROR" "$EXAMPLE"
4647
exit 1 ;;
4748
esac
@@ -89,6 +90,21 @@ logError(){
8990
printf "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
9091
}
9192

93+
# Unity Version -----------------------------------------------------------------
94+
95+
# This is the path to the logs from the standalone build job
96+
FILE="$build_logs/TestResults.js"
97+
98+
unity_version=$(sed -n 's/.*"editorVersion": *"\([^" (]*\).*/\1/p' $FILE)
99+
100+
# ensure arguments were passed and the ports are defined
101+
if [ -z "$unity_version" ]; then
102+
logMessage "Failed to find unity version! Exiting...";
103+
exit 1;
104+
else
105+
logMessage "Found Unity version: $unity_version";
106+
fi
107+
92108
# Protocol Buffer Compiler ------------------------------------------------------
93109

94110
# Apply any updates
@@ -140,7 +156,7 @@ cargo build --example ngo_echo_server
140156

141157
# Run the echo server in the background
142158
logMessage "Running echo server tests..."
143-
cargo run --example ngo_echo_server -- --port $echo_port &
159+
cargo run --example ngo_echo_server -- --port $echo_port --unity-version $unity_version &
144160

145161
# CMB Service -------------------------------------------------------------------
146162

@@ -152,6 +168,8 @@ cargo build --release --locked
152168
# The infinite loop is required as the service will exit each time all connected clients disconnect.
153169
# This means the service will exit after each test. The infinite loop will immediately restart the service each time it exits.
154170
logMessage "Running service integration tests..."
171+
echo "comb-server -l error --metrics-port 5000 standalone --port $service_port -t 60m --unity-version $unity_version"
172+
155173
while :; do
156-
./target/release/comb-server -l error --metrics-port 5000 standalone --port $service_port -t 60m;
174+
./target/release/comb-server -l error --metrics-port 5000 standalone --port $service_port -t 60m --unity-version $unity_version;
157175
done & # <- use & to run the entire loop in the background

com.unity.netcode.gameobjects/Tests/Runtime/Rpc/RpcInvocationTests.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ public RpcInvocationTests(NetworkTopologyTypes topologyType) : base(topologyType
2323

2424
private Dictionary<NetworkManager, InvokePermissionBehaviour> m_InvokeInstances = new();
2525

26-
// TODO: [CmbServiceTests] Enable once the CMB service fixes the client spoofing issue.
27-
protected override bool UseCMBService() => false;
28-
2926
protected override void OnServerAndClientsCreated()
3027
{
3128
m_Prefab = CreateNetworkObjectPrefab("RpcInvokePermissionTest");

testproject/Assets/Tests/Runtime/SceneObjectsNotDestroyedOnShutdownTest.cs

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,25 @@
1010

1111
namespace TestProject.RuntimeTests
1212
{
13+
[TestFixture(NetworkTopologyTypes.ClientServer)]
14+
[TestFixture(NetworkTopologyTypes.DistributedAuthority)]
1315
public class SceneObjectsNotDestroyedOnShutdownTest : NetcodeIntegrationTest
1416
{
1517
protected override int NumberOfClients => 0;
1618

1719
private const string k_TestScene = "InSceneNetworkObject";
1820
private const string k_SceneObjectName = "InSceneObject";
1921
private Scene m_TestScene;
20-
private WaitForSeconds m_DefaultWaitForTick = new WaitForSeconds(1.0f / 30);
22+
private WaitForSeconds m_DefaultWaitForTick = new(1.0f / 30);
2123

22-
// TODO: [CmbServiceTests] Adapt to run with the service
23-
protected override bool UseCMBService()
24-
{
25-
return false;
26-
}
24+
public SceneObjectsNotDestroyedOnShutdownTest(NetworkTopologyTypes topology) : base(topology) { }
2725

2826
[UnityTest]
2927
public IEnumerator SceneObjectsNotDestroyedOnShutdown()
3028
{
31-
m_ServerNetworkManager.SceneManager.OnSceneEvent += SceneManager_OnSceneEvent;
32-
m_ServerNetworkManager.SceneManager.LoadScene(k_TestScene, LoadSceneMode.Additive);
29+
var authority = GetAuthorityNetworkManager();
30+
authority.SceneManager.OnSceneEvent += SceneManager_OnSceneEvent;
31+
authority.SceneManager.LoadScene(k_TestScene, LoadSceneMode.Additive);
3332

3433
yield return WaitForConditionOrTimeOut(() => m_TestScene.IsValid() && m_TestScene.isLoaded);
3534
AssertOnTimeout($"Timed out waiting for scene {k_TestScene} to load!");
@@ -38,11 +37,12 @@ public IEnumerator SceneObjectsNotDestroyedOnShutdown()
3837

3938
AssertOnTimeout($"Timed out waiting to find {k_SceneObjectName} after scene load and before starting client!\"");
4039

41-
yield return CreateAndStartNewClient();
40+
var lateJoin = CreateNewClient();
41+
yield return StartClient(lateJoin);
4242

4343
var loadedInSceneObjects = Object.FindObjectsByType<NetworkObject>(FindObjectsSortMode.InstanceID).Where((c) => c.name.Contains(k_SceneObjectName));
4444
Assert.IsTrue(loadedInSceneObjects.Count() > 1, $"Only found one instance of {k_SceneObjectName} after client connected!");
45-
m_ClientNetworkManagers[0].Shutdown();
45+
lateJoin.Shutdown();
4646
yield return m_DefaultWaitForTick;
4747
loadedInSceneObjects = Object.FindObjectsByType<NetworkObject>(FindObjectsSortMode.InstanceID).Where((c) => c.name.Contains(k_SceneObjectName));
4848

@@ -52,36 +52,39 @@ public IEnumerator SceneObjectsNotDestroyedOnShutdown()
5252
[UnityTest]
5353
public IEnumerator ChildSceneObjectsDoNotDestroyOnShutdown()
5454
{
55-
m_ServerNetworkManager.SceneManager.OnSceneEvent += SceneManager_OnSceneEvent;
56-
m_ServerNetworkManager.SceneManager.LoadScene(k_TestScene, LoadSceneMode.Additive);
55+
var authority = GetAuthorityNetworkManager();
56+
authority.SceneManager.OnSceneEvent += SceneManager_OnSceneEvent;
57+
authority.SceneManager.LoadScene(k_TestScene, LoadSceneMode.Additive);
5758

5859
yield return WaitForConditionOrTimeOut(() => m_TestScene.IsValid() && m_TestScene.isLoaded);
5960
AssertOnTimeout($"Timed out waiting for scene {k_TestScene} to load!");
6061

6162
var loadedInSceneObject = Object.FindObjectsByType<NetworkObject>(FindObjectsSortMode.InstanceID).Where((c) => c.name.Contains(k_SceneObjectName)).FirstOrDefault();
6263
Assert.IsNotNull(loadedInSceneObject, $"Failed to find {k_SceneObjectName} before starting client!");
63-
yield return CreateAndStartNewClient();
6464

65-
var clientId = m_ClientNetworkManagers[0].LocalClientId;
66-
Assert.IsTrue(loadedInSceneObject.TrySetParent(m_PlayerNetworkObjects[0][clientId]), $"Failed to parent in-scene object under client player");
65+
var lateJoin = CreateNewClient();
66+
yield return StartClient(lateJoin);
67+
68+
var clientId = lateJoin.LocalClientId;
69+
Assert.IsTrue(loadedInSceneObject.TrySetParent(m_PlayerNetworkObjects[authority.LocalClientId][clientId]), $"Failed to parent in-scene object under client player");
6770

6871
yield return WaitForConditionOrTimeOut(() => PlayerHasChildren(clientId));
6972
AssertOnTimeout($"Client-{clientId} player never parented {k_SceneObjectName}!");
7073

7174
var loadedInSceneObjects = Object.FindObjectsByType<NetworkObject>(FindObjectsSortMode.InstanceID).Where((c) => c.name.Contains(k_SceneObjectName));
7275
Assert.IsTrue(loadedInSceneObjects.Count() > 1, $"Only found one instance of {k_SceneObjectName} after client connected!");
73-
m_ClientNetworkManagers[0].Shutdown();
76+
lateJoin.Shutdown();
7477
yield return m_DefaultWaitForTick;
7578

7679
// Sanity check to make sure the client's player no longer has any children
7780
yield return WaitForConditionOrTimeOut(() => PlayerNoLongerExistsWithChildren(clientId));
7881
AssertOnTimeout($"Client-{clientId} player still exits with children after client shutdown!");
7982

80-
loadedInSceneObjects = Object.FindObjectsByType<NetworkObject>(FindObjectsSortMode.InstanceID).Where((c) => c.name.Contains(k_SceneObjectName));
83+
loadedInSceneObjects = Object.FindObjectsByType<NetworkObject>(FindObjectsSortMode.InstanceID).Where(o => o.name.Contains(k_SceneObjectName)).ToArray();
8184
// Make sure any in-scene placed NetworkObject instantiated has no parent
82-
foreach (var insceneObject in loadedInSceneObjects)
85+
foreach (var inSceneObject in loadedInSceneObjects)
8386
{
84-
Assert.IsTrue(insceneObject.transform.parent == null, $"{insceneObject.name} is still parented!");
87+
Assert.IsTrue(inSceneObject.transform.parent == null, $"{inSceneObject.name} is still parented!");
8588
}
8689

8790
// We should have exactly 2 in-scene placed NetworkObjects remaining:
@@ -100,16 +103,17 @@ private bool PlayerHasChildren(ulong clientId)
100103

101104
private bool PlayerNoLongerExistsWithChildren(ulong clientId)
102105
{
103-
if (m_PlayerNetworkObjects[0].ContainsKey(clientId) && m_PlayerNetworkObjects[0][clientId] != null)
106+
var authorityId = GetAuthorityNetworkManager().LocalClientId;
107+
if (m_PlayerNetworkObjects[authorityId].ContainsKey(clientId) && m_PlayerNetworkObjects[authorityId][clientId] != null)
104108
{
105-
return m_PlayerNetworkObjects[0][clientId].transform.childCount == 0;
109+
return m_PlayerNetworkObjects[authorityId][clientId].transform.childCount == 0;
106110
}
107111
return true;
108112
}
109113

110114
private void SceneManager_OnSceneEvent(SceneEvent sceneEvent)
111115
{
112-
if (sceneEvent.ClientId != m_ServerNetworkManager.LocalClientId)
116+
if (sceneEvent.ClientId != GetAuthorityNetworkManager().LocalClientId)
113117
{
114118
return;
115119
}

testproject/Assets/Tests/Runtime/SenderIdTests.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,13 @@
1010

1111
namespace TestProject.RuntimeTests
1212
{
13-
14-
[TestFixture(NetworkTopologyTypes.DistributedAuthority)]
15-
[TestFixture(NetworkTopologyTypes.ClientServer)]
1613
public class SenderIdTests : NetcodeIntegrationTest
1714
{
1815
protected override int NumberOfClients => 2;
1916

20-
// TODO: [CmbServiceTests] Adapt to run with the service
21-
protected override bool UseCMBService()
22-
{
23-
return false;
24-
}
25-
2617
private NetworkManager FirstClient => m_ClientNetworkManagers[0];
2718
private NetworkManager SecondClient => m_ClientNetworkManagers[1];
2819

29-
public SenderIdTests(NetworkTopologyTypes networkTopologyType) : base(networkTopologyType) { }
30-
3120
[UnityTest]
3221
public IEnumerator WhenSendingMessageFromServerToClient_SenderIdIsCorrect()
3322
{

0 commit comments

Comments
 (0)