From 6bfddf38fadd0a6dd83fbea5d4dbded120dc18c3 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity <73188597+NoelStephensUnity@users.noreply.github.com> Date: Fri, 10 Sep 2021 09:32:02 -0500 Subject: [PATCH 1/7] Refactor The base requirements to build and run multiprocess stuff. --- .../MessageQueue/MessageQueueContainer.cs | 2 +- .../BaseMultiprocessTests.cs | 91 +++++++++++++------ .../Helpers/BuildMultiprocessTestPlayer.cs | 4 +- .../Helpers/MultiprocessOrchestration.cs | 77 ++++++++++++++-- .../NetworkVariablePerformanceTests.cs | 2 +- 5 files changed, 138 insertions(+), 38 deletions(-) diff --git a/com.unity.netcode.gameobjects/Runtime/Messaging/MessageQueue/MessageQueueContainer.cs b/com.unity.netcode.gameobjects/Runtime/Messaging/MessageQueue/MessageQueueContainer.cs index ae4fd4c25a..f7422c6fc6 100644 --- a/com.unity.netcode.gameobjects/Runtime/Messaging/MessageQueue/MessageQueueContainer.cs +++ b/com.unity.netcode.gameobjects/Runtime/Messaging/MessageQueue/MessageQueueContainer.cs @@ -813,7 +813,7 @@ public MessageQueueContainer(NetworkManager networkManager, uint maxFrameHistory } -#if UNITY_EDITOR || DEVELOPMENT_BUILD +#if UNITY_INCLUDE_TESTS /// /// Enables testing of the MessageQueueContainer /// diff --git a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs index 8771abffbd..2b0fe41428 100644 --- a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs +++ b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs @@ -19,81 +19,118 @@ public abstract class BaseMultiprocessTests { protected virtual bool IsPerformanceTest => true; - private const string k_GlobalEmptySceneName = "EmptyScene"; - - private bool m_SceneHasLoaded; - - protected bool ShouldIgnoreTests => IsPerformanceTest && Application.isEditor || MultiprocessOrchestration.IsUsingUTR(); // todo remove UTR check once we have proper automation - /// /// Implement this to specify the amount of workers to spawn from your main test runner - /// TODO there's a good chance this will be refactored with something fancier once we start integrating with bokken + /// TODO there's a good chance this will be re-factored with something fancier once we start integrating with bokken /// protected abstract int WorkerCount { get; } + private const string k_FirstPartOfTestRunnerSceneName = "InitTestScene"; + + // Since we want to additively load our BuildMultiprocessTestPlayer.MainSceneName + // We want to keep a reference to the + private Scene m_OriginalActiveScene; + [OneTimeSetUp] public virtual void SetupTestSuite() { - if (ShouldIgnoreTests) + if (IsPerformanceTest) + { + Assert.Ignore("Performance tests should be run from remote test execution on device (this can be ran using the \"run selected tests (your platform)\" button"); + } + + var currentlyActiveScene = SceneManager.GetActiveScene(); + + // Just adding a sanity check here to help with debugging in the event that SetupTestSuite is + // being invoked and the TestRunner scene has not been set to the active scene yet. + // This could mean that TeardownSuite wasn't called or SceneManager is not finished unloading + // or could not unload the BuildMultiprocessTestPlayer.MainSceneName. + if (!currentlyActiveScene.name.StartsWith(k_FirstPartOfTestRunnerSceneName)) { - Assert.Ignore("Ignoring tests that shouldn't run from unity editor. Performance tests should be run from remote test execution on device (this can be ran using the \"run selected tests (your platform)\" button"); + Debug.LogError($"Expected the currently active scene to begin with ({k_FirstPartOfTestRunnerSceneName}) but currently active scene is {currentlyActiveScene.name}"); } + m_OriginalActiveScene = currentlyActiveScene; - SceneManager.LoadScene(BuildMultiprocessTestPlayer.MainSceneName, LoadSceneMode.Single); SceneManager.sceneLoaded += OnSceneLoaded; + SceneManager.LoadScene(BuildMultiprocessTestPlayer.MainSceneName, LoadSceneMode.Additive); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { SceneManager.sceneLoaded -= OnSceneLoaded; + if (scene.name == BuildMultiprocessTestPlayer.MainSceneName) + { + SceneManager.SetActiveScene(scene); + } NetworkManager.Singleton.StartHost(); - for (int i = 0; i < WorkerCount; i++) + + // Use scene verification to make sure we don't try to get clients to synchronize the TestRunner scene + NetworkManager.Singleton.SceneManager.VerifySceneBeforeLoading = VerifySceneIsValidForClientsToLoad; + } + + /// + /// We want to exclude the TestRunner scene on the host-server side so it won't try to tell clients to + /// synchronize to this scene when they connect (host-server side only for multiprocess) + /// + /// true - scene is fine to synchronize/inform clients to load and false - scene should not be loaded by clients + private bool VerifySceneIsValidForClientsToLoad(int sceneIndex, string sceneName, LoadSceneMode loadSceneMode) + { + if (sceneName.StartsWith(k_FirstPartOfTestRunnerSceneName)) { - MultiprocessOrchestration.StartWorkerNode(); // will automatically start built player as clients + return false; } - - m_SceneHasLoaded = true; + return true; } [UnitySetUp] public virtual IEnumerator Setup() { - yield return new WaitUntil(() => NetworkManager.Singleton != null && NetworkManager.Singleton.IsServer && m_SceneHasLoaded); - + yield return new WaitUntil(() => NetworkManager.Singleton != null && NetworkManager.Singleton.IsServer && NetworkManager.Singleton.IsListening); var startTime = Time.time; + + // Moved this out of OnSceneLoaded as OnSceneLoaded is a callback from the SceneManager and just wanted to avoid creating + // processes from within the same callstack/context as the SceneManager. This will instantiate up to the WorkerCount and + // then any subsequent calls to Setup if there are already workers it will skip this step + if (MultiprocessOrchestration.Processes.Count < WorkerCount) + { + var numProcessesToCreate = WorkerCount - MultiprocessOrchestration.Processes.Count; + for (int i = 0; i < numProcessesToCreate; i++) + { + MultiprocessOrchestration.StartWorkerNode(); // will automatically start built player as clients + } + } + + var timeOutTime = Time.realtimeSinceStartup + TestCoordinator.MaxWaitTimeoutSec; while (NetworkManager.Singleton.ConnectedClients.Count <= WorkerCount) { yield return new WaitForSeconds(0.2f); - if (Time.time - startTime > TestCoordinator.MaxWaitTimeoutSec) + if (Time.realtimeSinceStartup > timeOutTime) { throw new Exception($"waiting too long to see clients to connect, got {NetworkManager.Singleton.ConnectedClients.Count - 1} clients, but was expecting {WorkerCount}, failing"); } } - TestCoordinator.Instance.KeepAliveClientRpc(); } [TearDown] public virtual void Teardown() { - if (!ShouldIgnoreTests) - { - TestCoordinator.Instance.TestRunTeardown(); - } + TestCoordinator.Instance.TestRunTeardown(); } [OneTimeTearDown] public virtual void TeardownSuite() { - if (!ShouldIgnoreTests) + MultiprocessOrchestration.ShutdownAllProcesses(); + NetworkManager.Singleton.Shutdown(); + Object.Destroy(NetworkManager.Singleton.gameObject); // making sure we clear everything before reloading our scene + if (m_OriginalActiveScene.IsValid()) { - TestCoordinator.Instance.CloseRemoteClientRpc(); - NetworkManager.Singleton.Shutdown(); - Object.Destroy(NetworkManager.Singleton.gameObject); // making sure we clear everything before reloading our scene - SceneManager.LoadScene(k_GlobalEmptySceneName); // using empty scene to clear our state + SceneManager.SetActiveScene(m_OriginalActiveScene); } + SceneManager.UnloadSceneAsync(BuildMultiprocessTestPlayer.MainSceneName); } } } diff --git a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/BuildMultiprocessTestPlayer.cs b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/BuildMultiprocessTestPlayer.cs index ba104069cb..4346ad953a 100644 --- a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/BuildMultiprocessTestPlayer.cs +++ b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/BuildMultiprocessTestPlayer.cs @@ -87,10 +87,10 @@ private static BuildReport BuildPlayer(bool isDebug = false) } Debug.Log($"Starting multiprocess player build using path {buildPathToUse}"); - + // Include all EditorBuildSettings.scenes with clients so they are in alignment with the server's scenes in build list indices buildOptions &= ~BuildOptions.AutoRunPlayer; var buildReport = BuildPipeline.BuildPlayer( - new[] { $"Assets/Scenes/{MainSceneName}.unity" }, + EditorBuildSettings.scenes, buildPathToUse, EditorUserBuildSettings.activeBuildTarget, buildOptions); diff --git a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/MultiprocessOrchestration.cs b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/MultiprocessOrchestration.cs index 3aca8b52b7..49548c5c90 100644 --- a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/MultiprocessOrchestration.cs +++ b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/MultiprocessOrchestration.cs @@ -1,37 +1,75 @@ using System; +using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; +using System.Runtime.InteropServices; using Unity.Netcode.MultiprocessRuntimeTests; -using System.Linq; using UnityEngine; using Debug = UnityEngine.Debug; public class MultiprocessOrchestration { public const string IsWorkerArg = "-isWorker"; + private static DirectoryInfo s_MultiprocessDirInfo; + public static List Processes = new List(); public static void StartWorkerNode() { + if (Processes == null) + { + Processes = new List(); + } + + string userprofile = ""; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + userprofile = Environment.GetEnvironmentVariable("USERPROFILE"); + } + else + { + userprofile = Environment.GetEnvironmentVariable("HOME"); + } + // Debug.Log($"userprofile is {userprofile}"); + s_MultiprocessDirInfo = new DirectoryInfo(Path.Combine(userprofile, ".multiprocess")); + var workerProcess = new Process(); + if (Processes.Count > 0) + { + string message = ""; + foreach (var p in Processes) + { + message += $" {p.Id} {p.HasExited} {p.StartTime} "; + } + Debug.Log($"Current process count {Processes.Count} with data {message}"); + } + Processes.Add(workerProcess); //TODO this should be replaced eventually by proper orchestration for all supported platforms // Starting new local processes is a solution to help run perf tests locally. CI should have multi machine orchestration to // run performance tests with more realistic conditions. string buildInstructions = $"You probably didn't generate your build. Please make sure you build a player using the '{BuildMultiprocessTestPlayer.BuildAndExecuteMenuName}' menu"; + string extraArgs = ""; try { - var buildPath = BuildMultiprocessTestPlayer.ReadBuildInfo().BuildPath; switch (Application.platform) { case RuntimePlatform.OSXPlayer: case RuntimePlatform.OSXEditor: workerProcess.StartInfo.FileName = $"{buildPath}.app/Contents/MacOS/testproject"; + extraArgs += "-popupwindow -screen-width 100 -screen-height 100"; break; case RuntimePlatform.WindowsPlayer: case RuntimePlatform.WindowsEditor: workerProcess.StartInfo.FileName = $"{buildPath}.exe"; + extraArgs += "-popupwindow -screen-width 100 -screen-height 100"; + break; + case RuntimePlatform.LinuxPlayer: + case RuntimePlatform.LinuxEditor: + workerProcess.StartInfo.FileName = $"{buildPath}"; + extraArgs += "-nographics"; break; default: throw new NotImplementedException($"{nameof(StartWorkerNode)}: Current platform is not supported"); @@ -43,13 +81,18 @@ public static void StartWorkerNode() throw; } + string logPath = Path.Combine(s_MultiprocessDirInfo.FullName, $"logfile-mp{Processes.Count}"); + + workerProcess.StartInfo.UseShellExecute = false; workerProcess.StartInfo.RedirectStandardError = true; workerProcess.StartInfo.RedirectStandardOutput = true; - workerProcess.StartInfo.Arguments = $"{IsWorkerArg} -popupwindow -screen-width 100 -screen-height 100"; - // workerNode.StartInfo.Arguments += " -deepprofiling"; // enable for deep profiling + + workerProcess.StartInfo.Arguments = $"{IsWorkerArg} {extraArgs} -logFile {logPath} -s {BuildMultiprocessTestPlayer.MainSceneName}"; + try { + Debug.Log($"Attempting to start new process, current process count: {Processes.Count}"); var newProcessStarted = workerProcess.Start(); if (!newProcessStarted) { @@ -63,9 +106,29 @@ public static void StartWorkerNode() } } - // todo remove this once we have proper automation - public static bool IsUsingUTR() + public static void ShutdownAllProcesses() { - return Environment.GetCommandLineArgs().Contains("-automated"); + Debug.Log("Shutting down all processes.."); + foreach (var process in Processes) + { + Debug.Log($"Shutting down process {process.Id} with state {process.HasExited}"); + try + { + if (!process.HasExited) + { + // Close process by sending a close message to its main window. + process.CloseMainWindow(); + + // Free resources associated with process. + process.Close(); + } + } + catch (Exception ex) + { + Debug.LogException(ex); + } + } + + Processes.Clear(); } } diff --git a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/NetworkVariablePerformanceTests.cs b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/NetworkVariablePerformanceTests.cs index 9cc1d5f5b9..101c8c2a28 100644 --- a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/NetworkVariablePerformanceTests.cs +++ b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/NetworkVariablePerformanceTests.cs @@ -231,7 +231,7 @@ void UpdateWaitForAllOneNetVarToDespawnFunc(float deltaTime) public override void TeardownSuite() { base.TeardownSuite(); - if (!ShouldIgnoreTests) + if (!IsPerformanceTest) { s_ServerObjectPool.Dispose(); } From 101e0c474a519a493790e97043c0e2b5ecf38a9d Mon Sep 17 00:00:00 2001 From: Noel Stephens Date: Fri, 10 Sep 2021 10:12:00 -0500 Subject: [PATCH 2/7] style removing LF --- .../Runtime/Messaging/MessageQueue/MessageQueueContainer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/Runtime/Messaging/MessageQueue/MessageQueueContainer.cs b/com.unity.netcode.gameobjects/Runtime/Messaging/MessageQueue/MessageQueueContainer.cs index f7422c6fc6..ff29b4f324 100644 --- a/com.unity.netcode.gameobjects/Runtime/Messaging/MessageQueue/MessageQueueContainer.cs +++ b/com.unity.netcode.gameobjects/Runtime/Messaging/MessageQueue/MessageQueueContainer.cs @@ -812,7 +812,6 @@ public MessageQueueContainer(NetworkManager networkManager, uint maxFrameHistory Initialize(maxFrameHistory); } - #if UNITY_INCLUDE_TESTS /// /// Enables testing of the MessageQueueContainer From 639a0f53b5d8425c59de78c375db3d25173a6cf2 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity <73188597+NoelStephensUnity@users.noreply.github.com> Date: Mon, 13 Sep 2021 12:22:42 -0500 Subject: [PATCH 3/7] fix Adding back the multiprocess ignore capabilities with the ability to easily override this ignore for continued development work. --- .../BaseMultiprocessTests.cs | 29 ++++++++++++++----- .../Helpers/MultiprocessOrchestration.cs | 10 +++++++ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs index 2b0fe41428..e8a0cf5333 100644 --- a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs +++ b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs @@ -17,6 +17,10 @@ public MultiprocessTestsAttribute() : base(MultiprocessCategoryName) { } [MultiprocessTests] public abstract class BaseMultiprocessTests { + // TODO: Remove UTR check once we have Multiprocess tests fully working + protected bool IgnorMultiprocessTests => MultiprocessOrchestration.ShouldIgnoreUTRTests(); + + protected virtual bool IsPerformanceTest => true; /// @@ -34,6 +38,11 @@ public abstract class BaseMultiprocessTests [OneTimeSetUp] public virtual void SetupTestSuite() { + if (IgnorMultiprocessTests) + { + Assert.Ignore("Ignoring tests under UTR. For testing, include the \"-bypassIgnoreUTR\" command line parameter."); + } + if (IsPerformanceTest) { Assert.Ignore("Performance tests should be run from remote test execution on device (this can be ran using the \"run selected tests (your platform)\" button"); @@ -117,20 +126,26 @@ public virtual IEnumerator Setup() [TearDown] public virtual void Teardown() { - TestCoordinator.Instance.TestRunTeardown(); + if (!IgnorMultiprocessTests) + { + TestCoordinator.Instance.TestRunTeardown(); + } } [OneTimeTearDown] public virtual void TeardownSuite() { - MultiprocessOrchestration.ShutdownAllProcesses(); - NetworkManager.Singleton.Shutdown(); - Object.Destroy(NetworkManager.Singleton.gameObject); // making sure we clear everything before reloading our scene - if (m_OriginalActiveScene.IsValid()) + if (!IgnorMultiprocessTests) { - SceneManager.SetActiveScene(m_OriginalActiveScene); + MultiprocessOrchestration.ShutdownAllProcesses(); + NetworkManager.Singleton.Shutdown(); + Object.Destroy(NetworkManager.Singleton.gameObject); // making sure we clear everything before reloading our scene + if (m_OriginalActiveScene.IsValid()) + { + SceneManager.SetActiveScene(m_OriginalActiveScene); + } + SceneManager.UnloadSceneAsync(BuildMultiprocessTestPlayer.MainSceneName); } - SceneManager.UnloadSceneAsync(BuildMultiprocessTestPlayer.MainSceneName); } } } diff --git a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/MultiprocessOrchestration.cs b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/MultiprocessOrchestration.cs index 49548c5c90..fdaffd67c5 100644 --- a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/MultiprocessOrchestration.cs +++ b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/MultiprocessOrchestration.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; @@ -14,6 +15,15 @@ public class MultiprocessOrchestration private static DirectoryInfo s_MultiprocessDirInfo; public static List Processes = new List(); + /// + /// This is to detect if we should ignore Multiprocess tests + /// For testing, include the -bypassIgnoreUTR command line parameter when running UTR. + /// + public static bool ShouldIgnoreUTRTests() + { + return Environment.GetCommandLineArgs().Contains("-automated") && !Environment.GetCommandLineArgs().Contains("-bypassIgnoreUTR"); + } + public static void StartWorkerNode() { if (Processes == null) From 10790a8ac16be62a55c0b18cca7ef866d478b614 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity <73188597+NoelStephensUnity@users.noreply.github.com> Date: Mon, 13 Sep 2021 12:44:27 -0500 Subject: [PATCH 4/7] fix including the IgnorMultiprocessTests test check for the NetworkVariablePerformanceTests --- .../NetworkVariablePerformanceTests.cs | 61 +++++++++++-------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/NetworkVariablePerformanceTests.cs b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/NetworkVariablePerformanceTests.cs index 101c8c2a28..fa97badc33 100644 --- a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/NetworkVariablePerformanceTests.cs +++ b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/NetworkVariablePerformanceTests.cs @@ -46,7 +46,10 @@ public static void Stop() public override void SetupTestSuite() { base.SetupTestSuite(); - SceneManager.sceneLoaded += OnSceneLoadedInitSetupSuite; + if (!IgnorMultiprocessTests) + { + SceneManager.sceneLoaded += OnSceneLoadedInitSetupSuite; + } } private void OnSceneLoadedInitSetupSuite(Scene scene, LoadSceneMode loadSceneMode) @@ -190,48 +193,52 @@ void UpdateFunc(float deltaTime) [UnityTearDown, MultiprocessContextBasedTest] public IEnumerator UnityTeardown() { - InitializeContextSteps(); - - yield return new ExecuteStepInContext(StepExecutionContext.Server, bytes => + if (!IgnorMultiprocessTests) { - foreach (var spawnedObject in m_ServerSpawnedObjects) + InitializeContextSteps(); + + yield return new ExecuteStepInContext(StepExecutionContext.Server, bytes => { - spawnedObject.NetworkObject.Despawn(); - s_ServerObjectPool.Release(spawnedObject); - StopSpawnedObject(spawnedObject); - } + foreach (var spawnedObject in m_ServerSpawnedObjects) + { + spawnedObject.NetworkObject.Despawn(); + s_ServerObjectPool.Release(spawnedObject); + StopSpawnedObject(spawnedObject); + } - m_ServerSpawnedObjects.Clear(); - }); + m_ServerSpawnedObjects.Clear(); + }); - yield return new ExecuteStepInContext(StepExecutionContext.Clients, bytes => - { - NetworkManager.Singleton.gameObject.GetComponent().OnUpdate = null; // todo move access to callbackcomponent to singleton + yield return new ExecuteStepInContext(StepExecutionContext.Clients, bytes => + { + NetworkManager.Singleton.gameObject.GetComponent().OnUpdate = null; // todo move access to callbackcomponent to singleton void UpdateWaitForAllOneNetVarToDespawnFunc(float deltaTime) - { - if (OneNetVar.InstanceCount == 0) { - NetworkManager.Singleton.gameObject.GetComponent().OnUpdate -= UpdateWaitForAllOneNetVarToDespawnFunc; - TestCoordinator.Instance.ClientFinishedServerRpc(); + if (OneNetVar.InstanceCount == 0) + { + NetworkManager.Singleton.gameObject.GetComponent().OnUpdate -= UpdateWaitForAllOneNetVarToDespawnFunc; + TestCoordinator.Instance.ClientFinishedServerRpc(); + } } - } - NetworkManager.Singleton.gameObject.GetComponent().OnUpdate += UpdateWaitForAllOneNetVarToDespawnFunc; - }, waitMultipleUpdates: true, ignoreTimeoutException: true); // ignoring timeout since you don't want to hide any issues in the main tests + NetworkManager.Singleton.gameObject.GetComponent().OnUpdate += UpdateWaitForAllOneNetVarToDespawnFunc; + }, waitMultipleUpdates: true, ignoreTimeoutException: true); // ignoring timeout since you don't want to hide any issues in the main tests - yield return new ExecuteStepInContext(StepExecutionContext.Clients, _ => - { - m_ClientPrefabHandler.Dispose(); - NetworkManager.Singleton.PrefabHandler.RemoveHandler(m_PrefabToSpawn.NetworkObject); - }); + yield return new ExecuteStepInContext(StepExecutionContext.Clients, _ => + { + m_ClientPrefabHandler.Dispose(); + NetworkManager.Singleton.PrefabHandler.RemoveHandler(m_PrefabToSpawn.NetworkObject); + }); + } + yield return null; } [OneTimeTearDown] public override void TeardownSuite() { base.TeardownSuite(); - if (!IsPerformanceTest) + if (!IsPerformanceTest && !IgnorMultiprocessTests) { s_ServerObjectPool.Dispose(); } From d6db12b88f8ea0d74414f90b3e46526eb7850ce5 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity <73188597+NoelStephensUnity@users.noreply.github.com> Date: Mon, 13 Sep 2021 14:06:42 -0500 Subject: [PATCH 5/7] style fixing white space formatting issue due to indentation. --- .../MultiprocessRuntime/NetworkVariablePerformanceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/NetworkVariablePerformanceTests.cs b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/NetworkVariablePerformanceTests.cs index fa97badc33..fac5fe0c52 100644 --- a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/NetworkVariablePerformanceTests.cs +++ b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/NetworkVariablePerformanceTests.cs @@ -213,7 +213,7 @@ public IEnumerator UnityTeardown() { NetworkManager.Singleton.gameObject.GetComponent().OnUpdate = null; // todo move access to callbackcomponent to singleton - void UpdateWaitForAllOneNetVarToDespawnFunc(float deltaTime) + void UpdateWaitForAllOneNetVarToDespawnFunc(float deltaTime) { if (OneNetVar.InstanceCount == 0) { From 15ffc121f92f73d834d7bfe0358c3eba09c2f5c5 Mon Sep 17 00:00:00 2001 From: Noel Stephens Date: Tue, 14 Sep 2021 16:31:17 -0500 Subject: [PATCH 6/7] Update testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs Co-authored-by: M. Fatih MAR --- .../Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs index e8a0cf5333..fa6021b610 100644 --- a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs +++ b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs @@ -18,7 +18,7 @@ public MultiprocessTestsAttribute() : base(MultiprocessCategoryName) { } public abstract class BaseMultiprocessTests { // TODO: Remove UTR check once we have Multiprocess tests fully working - protected bool IgnorMultiprocessTests => MultiprocessOrchestration.ShouldIgnoreUTRTests(); + protected bool IgnoreMultiprocessTests => MultiprocessOrchestration.ShouldIgnoreUTRTests(); protected virtual bool IsPerformanceTest => true; From 2ccbc7f6bd3baf2fa298634010f0efee976083e5 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity <73188597+NoelStephensUnity@users.noreply.github.com> Date: Tue, 14 Sep 2021 16:54:32 -0500 Subject: [PATCH 7/7] fix spelling of IgnoreMultiprocessTests --- .../Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs | 6 +++--- .../MultiprocessRuntime/NetworkVariablePerformanceTests.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs index fa6021b610..cf9eb2ee6e 100644 --- a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs +++ b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs @@ -38,7 +38,7 @@ public abstract class BaseMultiprocessTests [OneTimeSetUp] public virtual void SetupTestSuite() { - if (IgnorMultiprocessTests) + if (IgnoreMultiprocessTests) { Assert.Ignore("Ignoring tests under UTR. For testing, include the \"-bypassIgnoreUTR\" command line parameter."); } @@ -126,7 +126,7 @@ public virtual IEnumerator Setup() [TearDown] public virtual void Teardown() { - if (!IgnorMultiprocessTests) + if (!IgnoreMultiprocessTests) { TestCoordinator.Instance.TestRunTeardown(); } @@ -135,7 +135,7 @@ public virtual void Teardown() [OneTimeTearDown] public virtual void TeardownSuite() { - if (!IgnorMultiprocessTests) + if (!IgnoreMultiprocessTests) { MultiprocessOrchestration.ShutdownAllProcesses(); NetworkManager.Singleton.Shutdown(); diff --git a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/NetworkVariablePerformanceTests.cs b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/NetworkVariablePerformanceTests.cs index fac5fe0c52..4f55b6a518 100644 --- a/testproject/Assets/Tests/Runtime/MultiprocessRuntime/NetworkVariablePerformanceTests.cs +++ b/testproject/Assets/Tests/Runtime/MultiprocessRuntime/NetworkVariablePerformanceTests.cs @@ -46,7 +46,7 @@ public static void Stop() public override void SetupTestSuite() { base.SetupTestSuite(); - if (!IgnorMultiprocessTests) + if (!IgnoreMultiprocessTests) { SceneManager.sceneLoaded += OnSceneLoadedInitSetupSuite; } @@ -193,7 +193,7 @@ void UpdateFunc(float deltaTime) [UnityTearDown, MultiprocessContextBasedTest] public IEnumerator UnityTeardown() { - if (!IgnorMultiprocessTests) + if (!IgnoreMultiprocessTests) { InitializeContextSteps(); @@ -238,7 +238,7 @@ void UpdateWaitForAllOneNetVarToDespawnFunc(float deltaTime) public override void TeardownSuite() { base.TeardownSuite(); - if (!IsPerformanceTest && !IgnorMultiprocessTests) + if (!IsPerformanceTest && !IgnoreMultiprocessTests) { s_ServerObjectPool.Dispose(); }