Skip to content

Commit 5e76d8e

Browse files
test: remote config support for multiprocesstestscene (#1931)
* integrate multi-machine testing code * Reconfigure how host/client ip/port is set * PR feedback * Undetected compilation error * update to use async await * use async await * Use async/await and avoid call to Wait() * Clean up whitespace as well as remove calls to Wait() * only whitespace * attempt to move setting up StartClient to support async config * Continued experiments * Start client after the configuration has been set * Use notifications and callbacks instead of waits to enable TestCoordinator when the connection is complete * Make startclient call explicit * Test Coordinator cleanup for INotifyPropertyChanged * Fix whitespace * Fix whitespace, simplify Co-authored-by: Noel Stephens <[email protected]>
1 parent ae28805 commit 5e76d8e

File tree

10 files changed

+307
-50
lines changed

10 files changed

+307
-50
lines changed

testproject/Assets/Scenes/MultiprocessTestScene.unity

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RenderSettings:
3838
m_ReflectionIntensity: 1
3939
m_CustomReflection: {fileID: 0}
4040
m_Sun: {fileID: 0}
41-
m_IndirectSpecularColor: {r: 0.44657838, g: 0.49641234, b: 0.57481676, a: 1}
41+
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
4242
m_UseRadianceAmbientProbe: 0
4343
--- !u!157 &3
4444
LightmapSettings:
@@ -212,7 +212,6 @@ Transform:
212212
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
213213
m_LocalPosition: {x: 0, y: 3, z: 0}
214214
m_LocalScale: {x: 1, y: 1, z: 1}
215-
m_ConstrainProportionsScale: 0
216215
m_Children: []
217216
m_Father: {fileID: 0}
218217
m_RootOrder: 1
@@ -223,8 +222,8 @@ LightingSettings:
223222
m_CorrespondingSourceObject: {fileID: 0}
224223
m_PrefabInstance: {fileID: 0}
225224
m_PrefabAsset: {fileID: 0}
226-
m_Name:
227-
serializedVersion: 4
225+
m_Name:
226+
serializedVersion: 3
228227
m_GIWorkflowMode: 1
229228
m_EnableBakedLightmaps: 1
230229
m_EnableRealtimeLightmaps: 0
@@ -237,7 +236,7 @@ LightingSettings:
237236
m_LightmapMaxSize: 1024
238237
m_BakeResolution: 40
239238
m_Padding: 2
240-
m_LightmapCompression: 3
239+
m_TextureCompression: 1
241240
m_AO: 0
242241
m_AOMaxDistance: 1
243242
m_CompAOExponent: 1
@@ -278,7 +277,6 @@ LightingSettings:
278277
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
279278
m_PVRFilteringAtrousPositionSigmaIndirect: 2
280279
m_PVRFilteringAtrousPositionSigmaAO: 1
281-
m_PVRTiledBaking: 0
282280
--- !u!1 &160940364
283281
GameObject:
284282
m_ObjectHideFlags: 0
@@ -371,7 +369,6 @@ Transform:
371369
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
372370
m_LocalPosition: {x: -10, y: -10, z: -10}
373371
m_LocalScale: {x: 1, y: 1, z: 1}
374-
m_ConstrainProportionsScale: 0
375372
m_Children: []
376373
m_Father: {fileID: 0}
377374
m_RootOrder: 5
@@ -405,10 +402,10 @@ MonoBehaviour:
405402
m_Enabled: 1
406403
m_EditorHideFlags: 0
407404
m_Script: {fileID: 11500000, guid: 04cf3cc1396054b009a1ed283aa50021, type: 3}
408-
m_Name:
409-
m_EditorClassIdentifier:
405+
m_Name:
406+
m_EditorClassIdentifier:
410407
IsTestCoordinatorActiveAndEnabled: 0
411-
CommandLineArguments:
408+
CommandLineArguments:
412409
--- !u!102 &430011405
413410
TextMesh:
414411
serializedVersion: 3
@@ -481,9 +478,8 @@ Transform:
481478
m_PrefabAsset: {fileID: 0}
482479
m_GameObject: {fileID: 430011403}
483480
m_LocalRotation: {x: 0.2164396, y: 0, z: 0, w: 0.97629607}
484-
m_LocalPosition: {x: -40, y: 0, z: 10}
481+
m_LocalPosition: {x: -45, y: 10, z: 10}
485482
m_LocalScale: {x: 1, y: 1, z: 1}
486-
m_ConstrainProportionsScale: 0
487483
m_Children: []
488484
m_Father: {fileID: 0}
489485
m_RootOrder: 7
@@ -567,7 +563,6 @@ Transform:
567563
m_LocalRotation: {x: 0.21736304, y: -0, z: -0, w: 0.97609085}
568564
m_LocalPosition: {x: 0, y: 9.15, z: -27.5}
569565
m_LocalScale: {x: 1, y: 1, z: 1}
570-
m_ConstrainProportionsScale: 0
571566
m_Children: []
572567
m_Father: {fileID: 0}
573568
m_RootOrder: 0
@@ -664,7 +659,6 @@ Transform:
664659
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
665660
m_LocalPosition: {x: 0, y: 0, z: 0}
666661
m_LocalScale: {x: 1, y: 1, z: 1}
667-
m_ConstrainProportionsScale: 0
668662
m_Children: []
669663
m_Father: {fileID: 0}
670664
m_RootOrder: 4
@@ -761,7 +755,6 @@ Transform:
761755
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
762756
m_LocalPosition: {x: 10, y: 10, z: 10}
763757
m_LocalScale: {x: 1, y: 1, z: 1}
764-
m_ConstrainProportionsScale: 0
765758
m_Children: []
766759
m_Father: {fileID: 0}
767760
m_RootOrder: 3
@@ -795,8 +788,8 @@ MonoBehaviour:
795788
m_Enabled: 1
796789
m_EditorHideFlags: 0
797790
m_Script: {fileID: 11500000, guid: 593a2fe42fa9d37498c96f9a383b6521, type: 3}
798-
m_Name:
799-
m_EditorClassIdentifier:
791+
m_Name:
792+
m_EditorClassIdentifier:
800793
RunInBackground: 1
801794
LogLevel: 1
802795
NetworkConfig:
@@ -814,7 +807,7 @@ MonoBehaviour:
814807
TickRate: 30
815808
ClientConnectionBufferTimeout: 10
816809
ConnectionApproval: 0
817-
ConnectionData:
810+
ConnectionData:
818811
EnableTimeResync: 0
819812
TimeResyncInterval: 30
820813
EnsureNetworkVariableLengthSafety: 0
@@ -836,7 +829,6 @@ Transform:
836829
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
837830
m_LocalPosition: {x: 0, y: 0, z: 0}
838831
m_LocalScale: {x: 1, y: 1, z: 1}
839-
m_ConstrainProportionsScale: 0
840832
m_Children:
841833
- {fileID: 1674777072}
842834
- {fileID: 2027640072}
@@ -853,8 +845,8 @@ MonoBehaviour:
853845
m_Enabled: 1
854846
m_EditorHideFlags: 0
855847
m_Script: {fileID: 11500000, guid: 068bf11ceb1344667af4cc40950f44f4, type: 3}
856-
m_Name:
857-
m_EditorClassIdentifier:
848+
m_Name:
849+
m_EditorClassIdentifier:
858850
ReferencedPrefab: {fileID: 9115731988109684252, guid: c2851feb7276442cc86a6f2d1d69ea11,
859851
type: 3}
860852
--- !u!114 &1211923378
@@ -867,8 +859,8 @@ MonoBehaviour:
867859
m_Enabled: 1
868860
m_EditorHideFlags: 0
869861
m_Script: {fileID: 11500000, guid: 55d1c75ce242745ac98f7e7aca6d2d19, type: 3}
870-
m_Name:
871-
m_EditorClassIdentifier:
862+
m_Name:
863+
m_EditorClassIdentifier:
872864
--- !u!1 &1274245423
873865
GameObject:
874866
m_ObjectHideFlags: 0
@@ -897,8 +889,8 @@ MonoBehaviour:
897889
m_Enabled: 1
898890
m_EditorHideFlags: 0
899891
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
900-
m_Name:
901-
m_EditorClassIdentifier:
892+
m_Name:
893+
m_EditorClassIdentifier:
902894
GlobalObjectIdHash: 2217825759
903895
AlwaysReplicateAsRoot: 0
904896
DontDestroyWithOwner: 0
@@ -913,7 +905,6 @@ Transform:
913905
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
914906
m_LocalPosition: {x: 10, y: 10, z: 10}
915907
m_LocalScale: {x: 1, y: 1, z: 1}
916-
m_ConstrainProportionsScale: 0
917908
m_Children: []
918909
m_Father: {fileID: 0}
919910
m_RootOrder: 6
@@ -928,8 +919,8 @@ MonoBehaviour:
928919
m_Enabled: 1
929920
m_EditorHideFlags: 0
930921
m_Script: {fileID: 11500000, guid: ef1240e0784f84eadb77fe822e2e03c7, type: 3}
931-
m_Name:
932-
m_EditorClassIdentifier:
922+
m_Name:
923+
m_EditorClassIdentifier:
933924
--- !u!1 &1674777071
934925
GameObject:
935926
m_ObjectHideFlags: 0
@@ -957,7 +948,6 @@ Transform:
957948
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
958949
m_LocalPosition: {x: 0, y: 0, z: 0}
959950
m_LocalScale: {x: 1, y: 1, z: 1}
960-
m_ConstrainProportionsScale: 0
961951
m_Children: []
962952
m_Father: {fileID: 1211923376}
963953
m_RootOrder: 0
@@ -972,8 +962,8 @@ MonoBehaviour:
972962
m_Enabled: 1
973963
m_EditorHideFlags: 0
974964
m_Script: {fileID: 11500000, guid: b84c2d8dfe509a34fb59e2b81f8e1319, type: 3}
975-
m_Name:
976-
m_EditorClassIdentifier:
965+
m_Name:
966+
m_EditorClassIdentifier:
977967
MessageBufferSize: 50000
978968
MaxConnections: 100
979969
MaxSentMessageQueueSize: 50000
@@ -1008,7 +998,6 @@ Transform:
1008998
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
1009999
m_LocalPosition: {x: 0, y: 0, z: 0}
10101000
m_LocalScale: {x: 1, y: 1, z: 1}
1011-
m_ConstrainProportionsScale: 0
10121001
m_Children: []
10131002
m_Father: {fileID: 1211923376}
10141003
m_RootOrder: 1
@@ -1023,8 +1012,8 @@ MonoBehaviour:
10231012
m_Enabled: 1
10241013
m_EditorHideFlags: 0
10251014
m_Script: {fileID: 11500000, guid: 6960e84d07fb87f47956e7a81d71c4e6, type: 3}
1026-
m_Name:
1027-
m_EditorClassIdentifier:
1015+
m_Name:
1016+
m_EditorClassIdentifier:
10281017
m_ProtocolType: 0
10291018
m_MaxPacketQueueSize: 128
10301019
m_MaxPayloadSize: 4096
@@ -1036,7 +1025,7 @@ MonoBehaviour:
10361025
ConnectionData:
10371026
Address: 127.0.0.1
10381027
Port: 7777
1039-
ServerListenAddress:
1028+
ServerListenAddress:
10401029
DebugSimulator:
10411030
PacketDelayMS: 0
10421031
PacketJitterMS: 0

testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
using UnityEngine.SceneManagement;
66
using UnityEngine.TestTools;
77
using Object = UnityEngine.Object;
8+
using Unity.Netcode.Transports.UNET;
9+
using Unity.Netcode.Transports.UTP;
10+
811

912
namespace Unity.Netcode.MultiprocessRuntimeTests
1013
{
@@ -77,6 +80,27 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
7780
SceneManager.SetActiveScene(scene);
7881
}
7982

83+
var transport = NetworkManager.Singleton.NetworkConfig.NetworkTransport;
84+
MultiprocessLogger.Log($"transport is {transport}");
85+
switch (transport)
86+
{
87+
case UNetTransport unetTransport:
88+
unetTransport.ConnectPort = int.Parse(TestCoordinator.Port);
89+
unetTransport.ServerListenPort = int.Parse(TestCoordinator.Port);
90+
unetTransport.ConnectAddress = "127.0.0.1";
91+
MultiprocessLogger.Log($"Setting ConnectAddress to {unetTransport.ConnectAddress} port {unetTransport.ConnectPort}, {unetTransport.ServerListenPort}");
92+
93+
break;
94+
case UnityTransport unityTransport:
95+
unityTransport.ConnectionData.ServerListenAddress = "0.0.0.0";
96+
MultiprocessLogger.Log($"Setting unityTransport.ConnectionData.Port {unityTransport.ConnectionData.ServerListenAddress}");
97+
break;
98+
default:
99+
MultiprocessLogger.LogError($"The transport {transport} has no case");
100+
break;
101+
}
102+
103+
MultiprocessLogger.Log("Starting Host");
80104
NetworkManager.Singleton.StartHost();
81105

82106
// Use scene verification to make sure we don't try to get clients to synchronize the TestRunner scene
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using UnityEngine;
2+
using System;
3+
using System.Net.Http;
4+
using System.Threading;
5+
using System.Collections.Generic;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace Unity.Netcode.MultiprocessRuntimeTests
10+
{
11+
public class ConfigurationTools
12+
{
13+
public static async Task<JobQueueItemArray> GetRemoteConfig()
14+
{
15+
var theList = new JobQueueItemArray();
16+
using var client = new HttpClient();
17+
var cancelAfterDelay = new CancellationTokenSource(TimeSpan.FromSeconds(10));
18+
var response = await client.GetAsync("https://multiprocess-log-event-manager.cds.internal.unity3d.com/api/JobWithFile",
19+
HttpCompletionOption.ResponseHeadersRead, cancelAfterDelay.Token).ConfigureAwait(false);
20+
var content = await response.Content.ReadAsStringAsync();
21+
JsonUtility.FromJsonOverwrite(content, theList);
22+
return theList;
23+
}
24+
25+
public static async void CompleteJobQueueItem(JobQueueItem item)
26+
{
27+
await PostJobQueueItem(item, "/complete");
28+
}
29+
30+
public static async void ClaimJobQueueItem(JobQueueItem item)
31+
{
32+
await PostJobQueueItem(item, "/claim");
33+
}
34+
35+
public static async Task PostJobQueueItem(JobQueueItem item, string path = "")
36+
{
37+
using var client = new HttpClient();
38+
using var request = new HttpRequestMessage(HttpMethod.Post, "https://multiprocess-log-event-manager.cds.internal.unity3d.com/api/JobWithFile" + path);
39+
var json = JsonUtility.ToJson(item);
40+
using var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
41+
request.Content = stringContent;
42+
MultiprocessLogger.Log($"Posting remoteConfig to server {json}");
43+
var cancelAfterDelay = new CancellationTokenSource(TimeSpan.FromSeconds(20));
44+
var response = await client
45+
.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancelAfterDelay.Token).ConfigureAwait(false);
46+
MultiprocessLogger.Log($"remoteConfig posted, checking response {response.StatusCode}");
47+
}
48+
}
49+
50+
[Serializable]
51+
public class JobQueueItemArray
52+
{
53+
public List<JobQueueItem> JobQueueItems;
54+
}
55+
56+
[Serializable]
57+
public class JobQueueItem
58+
{
59+
public int Id;
60+
public long JobId;
61+
public string GitHash;
62+
public string HostIp;
63+
public int PlatformId;
64+
public int JobStateId;
65+
public string CreatedBy;
66+
public string UpdatedBy;
67+
public string TransportName;
68+
}
69+
}

testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/ConfigurationTools.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
public enum ConfigurationType
3+
{
4+
Unknown,
5+
Remote,
6+
CommandLine,
7+
ResourceFile,
8+
Host
9+
}

testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/ConfigurationType.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/MultiprocessLogger.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ public static void LogWarning(string msg)
2828

2929
public class MultiprocessLogHandler : ILogHandler
3030
{
31+
public static long JobId;
32+
static MultiprocessLogHandler()
33+
{
34+
if (JobId == 0)
35+
{
36+
string sJobId = Environment.GetEnvironmentVariable("YAMATO_JOB_ID");
37+
if (!long.TryParse(sJobId, out JobId))
38+
{
39+
JobId = -2;
40+
}
41+
}
42+
}
3143
public void LogException(Exception exception, UnityEngine.Object context)
3244
{
3345
Debug.unityLogger.LogException(exception, context);

testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/MultiprocessOrchestration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public static string StartWorkerNode()
117117
case RuntimePlatform.WindowsEditor:
118118
workerProcess.StartInfo.FileName = $"{buildPath}.exe";
119119
//extraArgs += "-popupwindow -screen-width 100 -screen-height 100";
120-
extraArgs += "-batchmode -nographics";
120+
extraArgs += "-popupwindow";
121121
break;
122122
case RuntimePlatform.LinuxPlayer:
123123
case RuntimePlatform.LinuxEditor:

0 commit comments

Comments
 (0)