Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
6d185e5
moving orchestration to this branch from test/multiprocess-testing/wip
SamuelBellomo Jun 27, 2021
4f6d799
moving base for multiprocess tests to this branch from test/multiproc…
SamuelBellomo Jun 27, 2021
efb083c
adding fixed testcoordinator
SamuelBellomo Jun 27, 2021
bdaf320
Merge branch 'test/multiprocess-tests/orchestration' into test/multip…
SamuelBellomo Jun 27, 2021
4ea4d4c
adding missing change
SamuelBellomo Jun 27, 2021
ea7cdcf
moving execute step in context to this branch from test/multiprocess-…
SamuelBellomo Jun 27, 2021
4add65e
moving perf tests to this branch from test/multiprocess-testing/wip
SamuelBellomo Jun 27, 2021
5803269
taking changes from wip branch
SamuelBellomo Jun 27, 2021
43b3cbe
taking changes from wip branch
SamuelBellomo Jun 27, 2021
aa09b08
Merge branch 'test/multiprocess-tests/base-multiprocess-tests' into t…
SamuelBellomo Jun 27, 2021
5fcc7f6
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jun 27, 2021
c804d64
commenting out ExecuteStepInContext for better PR clarity
SamuelBellomo Jun 27, 2021
4165a10
Merge branch 'test/multiprocess-tests/base-multiprocess-tests' into t…
SamuelBellomo Jun 27, 2021
5a1d2ef
uncommenting here, this is where they should really be
SamuelBellomo Jun 27, 2021
8361c95
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jun 27, 2021
23e435a
cleanup
SamuelBellomo Jun 27, 2021
c400776
Merge branch 'test/multiprocess-tests/orchestration' into test/multip…
SamuelBellomo Jun 27, 2021
5197a3c
Merge branch 'test/multiprocess-tests/base-multiprocess-tests' into t…
SamuelBellomo Jun 27, 2021
34c7bdc
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jun 27, 2021
c38a957
better name
SamuelBellomo Jun 27, 2021
ad836c5
Merge branch 'test/multiprocess-tests/orchestration' into test/multip…
SamuelBellomo Jun 27, 2021
f60e75c
Merge branch 'test/multiprocess-tests/base-multiprocess-tests' into t…
SamuelBellomo Jun 27, 2021
e00926e
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jun 27, 2021
60b7d43
removing comment and putting better name
SamuelBellomo Jun 27, 2021
d77f03f
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jun 27, 2021
b1656ae
consistent naming
SamuelBellomo Jul 5, 2021
4ddcd25
Apply suggestions from code review
SamuelBellomo Jul 5, 2021
55e6853
Applying suggestions
SamuelBellomo Jul 5, 2021
310a78d
Merge branch 'test/multiprocess-tests/orchestration' of github.com:Un…
SamuelBellomo Jul 5, 2021
3da130d
Merge branch 'test/multiprocess-tests/orchestration' into test/multip…
SamuelBellomo Jul 5, 2021
17c7e7d
naming
SamuelBellomo Jul 5, 2021
7221712
should be kept public for following PR
SamuelBellomo Jul 5, 2021
4d0c72f
Merge branch 'test/multiprocess-tests/orchestration' into test/multip…
SamuelBellomo Jul 5, 2021
4ff1206
apply rename
SamuelBellomo Jul 5, 2021
ad7addb
Merge branch 'test/multiprocess-tests/base-multiprocess-tests' into t…
SamuelBellomo Jul 5, 2021
5888f18
rename
SamuelBellomo Jul 5, 2021
98c9d2b
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jul 5, 2021
62a1d58
using latest test framework
SamuelBellomo Jul 5, 2021
eeae93c
using proper list
SamuelBellomo Jul 5, 2021
520c20d
better exception
SamuelBellomo Jul 5, 2021
3dad45e
Merge branch 'test/multiprocess-tests/base-multiprocess-tests' into t…
SamuelBellomo Jul 5, 2021
80abc80
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jul 5, 2021
a3b98a0
Merge branch 'develop' into test/multiprocess-tests/orchestration
0xFA11 Jul 6, 2021
9885747
fix for unused method
SamuelBellomo Jul 6, 2021
4a902ab
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jul 6, 2021
240e4e0
correct spacing
SamuelBellomo Jul 6, 2021
b93ef11
removing comment and adding something a bit more dynamic
SamuelBellomo Jul 6, 2021
0b37b63
Merge branch 'test/multiprocess-tests/orchestration' of github.com:Un…
SamuelBellomo Jul 6, 2021
3cf743a
Merge branch 'test/multiprocess-tests/orchestration' into test/multip…
SamuelBellomo Jul 6, 2021
2f74194
Merge branch 'test/multiprocess-tests/base-multiprocess-tests' into t…
SamuelBellomo Jul 6, 2021
fad69e8
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jul 6, 2021
f6309e9
fix/cleanup asmdefs again
0xFA11 Jul 6, 2021
cd809ec
Apply suggestions from code review
SamuelBellomo Jul 6, 2021
8db3ac3
Merge branch 'test/multiprocess-tests/orchestration' into test/multip…
SamuelBellomo Jul 6, 2021
933df82
Merge branch 'test/multiprocess-tests/base-multiprocess-tests' into t…
SamuelBellomo Jul 6, 2021
f45df03
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jul 6, 2021
6f7469b
Merge branch 'develop' into test/multiprocess-tests/orchestration
0xFA11 Jul 8, 2021
29e05bb
no longer ignore '[Ss]treamingAssets/buildInfo.txt'
0xFA11 Jul 8, 2021
ed2519c
PR suggestions
SamuelBellomo Jul 8, 2021
b08561a
changing root menu
SamuelBellomo Jul 8, 2021
1c9fb6c
#
SamuelBellomo Jul 8, 2021
c6d3b4a
rename test scene
SamuelBellomo Jul 8, 2021
2aa372b
Update testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/B…
SamuelBellomo Jul 8, 2021
3b6bfd8
Merge branch 'test/multiprocess-tests/orchestration' of github.com:Un…
SamuelBellomo Jul 8, 2021
484700f
rename for test scene
SamuelBellomo Jul 8, 2021
0701716
Merge branch 'test/multiprocess-tests/orchestration' into test/multip…
SamuelBellomo Jul 8, 2021
cba7b19
proper rename for scene
SamuelBellomo Jul 8, 2021
bde44dd
Merge branch 'test/multiprocess-tests/base-multiprocess-tests' into t…
SamuelBellomo Jul 8, 2021
9fbfb5b
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jul 8, 2021
90fffe4
#
SamuelBellomo Jul 8, 2021
24e3608
Merge branch 'test/multiprocess-tests/orchestration' into test/multip…
SamuelBellomo Jul 8, 2021
544572f
Merge branch 'test/multiprocess-tests/base-multiprocess-tests' into t…
SamuelBellomo Jul 8, 2021
9601d2b
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jul 8, 2021
2c915e9
simpler flow
SamuelBellomo Jul 8, 2021
d083fb6
Merge branch 'test/multiprocess-tests/orchestration' into test/multip…
SamuelBellomo Jul 8, 2021
9a3bd9b
fixes
SamuelBellomo Jul 8, 2021
65b214c
Merge branch 'test/multiprocess-tests/orchestration' into test/multip…
SamuelBellomo Jul 8, 2021
945c7f3
Merge branch 'test/multiprocess-tests/base-multiprocess-tests' into t…
SamuelBellomo Jul 8, 2021
17c6b6d
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jul 8, 2021
f34841f
Merge branch 'develop' into test/multiprocess-tests/base-multiprocess…
SamuelBellomo Jul 8, 2021
2fba2c4
Merge branch 'test/multiprocess-tests/base-multiprocess-tests' into t…
SamuelBellomo Jul 8, 2021
ffdaeb6
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jul 8, 2021
070f6af
formatting issues
SamuelBellomo Jul 9, 2021
d1aea4a
Merge branch 'test/multiprocess-tests/base-multiprocess-tests' into t…
SamuelBellomo Jul 9, 2021
9df09cd
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jul 9, 2021
d29cc80
format fix
SamuelBellomo Jul 9, 2021
8f8f7ec
name fix
SamuelBellomo Jul 9, 2021
b833202
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jul 9, 2021
9d33c8c
#
SamuelBellomo Jul 9, 2021
5897561
format update
SamuelBellomo Jul 9, 2021
e64b12e
name fix
SamuelBellomo Jul 9, 2021
c8b4186
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jul 9, 2021
dfb97b2
format issues
SamuelBellomo Jul 9, 2021
be40cfd
#
SamuelBellomo Jul 9, 2021
750a3b5
#
SamuelBellomo Jul 9, 2021
1e14bd4
Merge branch 'test/multiprocess-tests/base-multiprocess-tests' into t…
SamuelBellomo Jul 9, 2021
fb5abaa
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jul 9, 2021
b15f3cd
Merge branch 'develop' into test/multiprocess-tests/base-multiprocess…
0xFA11 Jul 9, 2021
50398b3
fix for automation fail right now
SamuelBellomo Jul 9, 2021
3d4d863
Merge branch 'test/multiprocess-tests/base-multiprocess-tests' of git…
SamuelBellomo Jul 9, 2021
e18b84f
Merge branch 'test/multiprocess-tests/base-multiprocess-tests' into t…
SamuelBellomo Jul 9, 2021
8275189
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jul 9, 2021
8ab1f40
Merge branch 'develop' into test/multiprocess-tests/execute-step-in-c…
SamuelBellomo Jul 9, 2021
f0a637d
Merge branch 'test/multiprocess-tests/execute-step-in-context' into t…
SamuelBellomo Jul 9, 2021
dd26d58
Merge branch 'develop' into test/multiprocess-tests/adding-perf-tests…
SamuelBellomo Jul 12, 2021
5de07e4
fixing package version issues
SamuelBellomo Jul 12, 2021
b6f85b1
Merge branch 'develop' into test/multiprocess-tests/adding-perf-tests…
SamuelBellomo Jul 12, 2021
4d7941b
proper name for file according to format
SamuelBellomo Jul 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions testproject/Assets/Scenes/MultiprocessTestScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 068bf11ceb1344667af4cc40950f44f4, type: 3}
m_Name:
m_EditorClassIdentifier:
referencedPrefab: {fileID: 5637023994061915634, guid: b0952a471c5a147cb92f6afcdb648f8a,
ReferencedPrefab: {fileID: 5637023994061915634, guid: b0952a471c5a147cb92f6afcdb648f8a,
type: 3}
--- !u!114 &1211923378
MonoBehaviour:
Expand Down Expand Up @@ -817,8 +817,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ef1240e0784f84eadb77fe822e2e03c7, type: 3}
m_Name:
m_EditorClassIdentifier:
isRegistering: 0
hasRegistered: 0
--- !u!1 &1674777071
GameObject:
m_ObjectHideFlags: 0
Expand Down
8 changes: 8 additions & 0 deletions testproject/Assets/Scripts/ScriptsForAutomatedTesting.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using UnityEngine;

/// <summary>
/// Serves as access point from code to a prefab
/// </summary>
public class PrefabReference : MonoBehaviour
{
[SerializeField]
public GameObject ReferencedPrefab;

public static PrefabReference Instance { get; private set; }

public void Awake()
{
if (Instance != null)
{
Destroy(gameObject);
return;
}

Instance = this;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "ScriptsForAutomatedTesting",
"rootNamespace": "",
"references": [
"GUID:753245531f1b64a6ea7491ec63a5947c",
"GUID:1491147abca9d7d4bb7105af628b223e"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,91 +6,118 @@
#endif
using UnityEngine;

/// <summary>
/// This is needed as Unity throws "An abnormal situation has occurred: the PlayerLoop internal function has been called recursively. Please contact Customer Support with a sample project so that we can reproduce the problem and troubleshoot it."
/// when trying to build from Setup() steps in tests.
/// </summary>
public static class BuildMultiprocessTestPlayer
namespace MLAPI.MultiprocessRuntimeTests
{
public const string MultiprocessBaseMenuName = "MLAPI/Multiprocess Test";
public const string BuildAndExecuteMenuName = MultiprocessBaseMenuName + "/Build Test Player #t";
public const string MainSceneName = "MultiprocessTestScene";
private static string BuildPathDirectory => Path.Combine(Path.GetDirectoryName(Application.dataPath), "Builds", "MultiprocessTests");
public static string BuildPath => Path.Combine(BuildPathDirectory, "MultiprocessTestPlayer");
/// <summary>
/// This is needed as Unity throws "An abnormal situation has occurred: the PlayerLoop internal function has been called recursively. Please contact Customer Support with a sample project so that we can reproduce the problem and troubleshoot it."
/// when trying to build from Setup() steps in tests.
/// </summary>
public static class BuildMultiprocessTestPlayer
{
public const string MultiprocessBaseMenuName = "MLAPI/Multiprocess Test";
public const string BuildAndExecuteMenuName = MultiprocessBaseMenuName + "/Build Test Player #t";
public const string MainSceneName = "MultiprocessTestScene";

public const string BuildInfoFileName = "buildInfo.json";

private static string BuildPathDirectory => Path.Combine(Path.GetDirectoryName(Application.dataPath), "Builds", "MultiprocessTests");
public static string BuildPath => Path.Combine(BuildPathDirectory, "MultiprocessTestPlayer");

#if UNITY_EDITOR
[MenuItem(BuildAndExecuteMenuName)]
public static void BuildRelease()
{
var report = BuildPlayer();
if (report.summary.result != BuildResult.Succeeded)
[MenuItem(BuildAndExecuteMenuName)]
public static void BuildRelease()
{
throw new Exception($"Build failed! {report.summary.totalErrors} errors");
var report = BuildPlayer();
if (report.summary.result != BuildResult.Succeeded)
{
throw new Exception($"Build failed! {report.summary.totalErrors} errors");
}
}
}

[MenuItem(MultiprocessBaseMenuName + "/Build Test Player (Debug)")]
public static void BuildDebug()
{
var report = BuildPlayer(true);
if (report.summary.result != BuildResult.Succeeded)
[MenuItem(MultiprocessBaseMenuName + "/Build Test Player (Debug)")]
public static void BuildDebug()
{
throw new Exception($"Build failed! {report.summary.totalErrors} errors");
var report = BuildPlayer(true);
if (report.summary.result != BuildResult.Succeeded)
{
throw new Exception($"Build failed! {report.summary.totalErrors} errors");
}
}
}

[MenuItem(MultiprocessBaseMenuName + "/Delete Test Build")]
public static void DeleteBuild()
{
if (Directory.Exists(BuildPathDirectory))
[MenuItem(MultiprocessBaseMenuName + "/Delete Test Build")]
public static void DeleteBuild()
{
Directory.Delete(BuildPathDirectory, recursive: true);
if (Directory.Exists(BuildPathDirectory))
{
Directory.Delete(BuildPathDirectory, recursive: true);
}
else
{
Debug.Log($"[{nameof(BuildMultiprocessTestPlayer)}] build directory does not exist ({BuildPathDirectory}) not deleting anything");
}
}
else

/// <summary>
/// Needs a separate build than the standalone test builds since we don't want the player to try to connect to the editor to do test
/// reporting. We only want to main node to do that, worker nodes should be dumb
/// </summary>
/// <returns></returns>
private static BuildReport BuildPlayer(bool isDebug = false)
{
Debug.Log($"[{nameof(BuildMultiprocessTestPlayer)}] build directory does not exist ({BuildPathDirectory}) not deleting anything");
}
}
// Save standalone build path to file so we can read it from standalone tests (that are not running from editor)
SaveBuildInfo(new BuildInfo() { BuildPath = BuildPath, IsDebug = isDebug });

/// <summary>
/// Needs a separate build than the standalone test builds since we don't want the player to try to connect to the editor to do test
/// reporting. We only want to main node to do that, worker nodes should be dumb
/// </summary>
/// <returns></returns>
private static BuildReport BuildPlayer(bool isDebug = false)
{
// Save standalone build path to file so we can read it from standalone tests (that are not running from editor)
File.WriteAllText(Path.Combine(Application.streamingAssetsPath, MultiprocessOrchestration.BuildInfoFileName), BuildPath);
// deleting so we don't end up testing on outdated builds if there's a build failure
DeleteBuild();

// deleting so we don't end up testing on outdated builds if there's a build failure
DeleteBuild();
var buildOptions = BuildOptions.None;
buildOptions |= BuildOptions.IncludeTestAssemblies;
buildOptions |= BuildOptions.StrictMode;
if (isDebug)
{
buildOptions |= BuildOptions.Development;
buildOptions |= BuildOptions.AllowDebugging; // enable this if you want to debug your players. Your players

var buildOptions = BuildOptions.None;
buildOptions |= BuildOptions.IncludeTestAssemblies;
buildOptions |= BuildOptions.StrictMode;
if (isDebug)
{
buildOptions |= BuildOptions.Development;
buildOptions |= BuildOptions.AllowDebugging; // enable this if you want to debug your players. Your players
// will have more connection permission popups when launching though
// will have more connection permission popups when launching though
}

var buildPathToUse = BuildPath;
if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor)
{
buildPathToUse += ".exe";
}

Debug.Log($"Starting multiprocess player build using path {buildPathToUse}");

buildOptions &= ~BuildOptions.AutoRunPlayer;
var buildReport = BuildPipeline.BuildPlayer(
new[] { $"Assets/Scenes/{MainSceneName}.unity" },
buildPathToUse,
EditorUserBuildSettings.activeBuildTarget,
buildOptions);

Debug.Log("Build finished");
return buildReport;
}
#endif

var buildPathToUse = BuildPath;
if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor)
[Serializable]
public struct BuildInfo
{
buildPathToUse += ".exe";
public string BuildPath;
public bool IsDebug;
}
Debug.Log($"Starting multiprocess player build using path {buildPathToUse}");

buildOptions &= ~BuildOptions.AutoRunPlayer;
var buildReport = BuildPipeline.BuildPlayer(
new[] { $"Assets/Scenes/{MainSceneName}.unity" },
buildPathToUse,
EditorUserBuildSettings.activeBuildTarget,
buildOptions);
public static BuildInfo ReadBuildInfo()
{
var jsonString = File.ReadAllText(Path.Combine(Application.streamingAssetsPath, BuildInfoFileName));
return JsonUtility.FromJson<BuildInfo>(jsonString);
}

Debug.Log("Build finished");
return buildReport;
public static void SaveBuildInfo(BuildInfo toSave)
{
var buildInfoJson = JsonUtility.ToJson(toSave);
File.WriteAllText(Path.Combine(Application.streamingAssetsPath, BuildInfoFileName), buildInfoJson);
}
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using UnityEngine;
using MLAPI.Spawning;

namespace MLAPI.MultiprocessRuntimeTests
{
public class CustomPrefabSpawnerForPerformanceTests<T> : INetworkPrefabInstanceHandler, IDisposable where T : NetworkBehaviour
{
private GameObjectPool<T> m_ObjectPool;
private Action<T> m_SetupSpawnedObject;
private Action<T> m_OnRelease;

public CustomPrefabSpawnerForPerformanceTests(T prefabToSpawn, int maxObjectsToSpawn, Action<T> setupSpawnedObject, Action<T> onRelease)
{
m_ObjectPool = new GameObjectPool<T>();
m_ObjectPool.Initialize(maxObjectsToSpawn, prefabToSpawn);
m_SetupSpawnedObject = setupSpawnedObject;
m_OnRelease = onRelease;
}

public NetworkObject HandleNetworkPrefabSpawn(ulong ownerClientId, Vector3 position, Quaternion rotation)
{
var netBehaviour = m_ObjectPool.Get();
var networkObject = netBehaviour.NetworkObject;
Transform netTransform = networkObject.transform;
netTransform.position = position;
netTransform.rotation = rotation;
m_SetupSpawnedObject(netBehaviour);
return networkObject;
}

public void HandleNetworkPrefabDestroy(NetworkObject networkObject)
{
var behaviour = networkObject.gameObject.GetComponent<T>(); // todo expensive, only used in teardown for now, should optimize eventually
m_OnRelease(behaviour);
Transform netTransform = networkObject.transform;
netTransform.position = Vector3.zero;
netTransform.rotation = Quaternion.identity;
m_ObjectPool.Release(behaviour);
}

public void Dispose()
{
m_ObjectPool.Dispose();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading