com.unity.netcode.gameobjects@1.0.0-pre.7
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com). ## [1.0.0-pre.7] - 2022-04-01 ### Added - Added editor only check prior to entering into play mode if the currently open and active scene is in the build list and if not displays a dialog box asking the user if they would like to automatically add it prior to entering into play mode. (#1828) - Added `UnityTransport` implementation and `com.unity.transport` package dependency (#1823) - Added `NetworkVariableWritePermission` to `NetworkVariableBase` and implemented `Owner` client writable netvars. (#1762) - `UnityTransport` settings can now be set programmatically. (#1845) - `FastBufferWriter` and Reader IsInitialized property. (#1859) ### Changed - Updated `UnityTransport` dependency on `com.unity.transport` to 1.0.0 (#1849) ### Removed - Removed `SnapshotSystem` (#1852) - Removed `com.unity.modules.animation`, `com.unity.modules.physics` and `com.unity.modules.physics2d` dependencies from the package (#1812) - Removed `com.unity.collections` dependency from the package (#1849) ### Fixed - Fixed in-scene placed NetworkObjects not being found/ignored after a client disconnects and then reconnects. (#1850) - Fixed issue where `UnityTransport` send queues were not flushed when calling `DisconnectLocalClient` or `DisconnectRemoteClient`. (#1847) - Fixed NetworkBehaviour dependency verification check for an existing NetworkObject not searching from root parent transform relative GameObject. (#1841) - Fixed issue where entries were not being removed from the NetworkSpawnManager.OwnershipToObjectsTable. (#1838) - Fixed ClientRpcs would always send to all connected clients by default as opposed to only sending to the NetworkObject's Observers list by default. (#1836) - Fixed clarity for NetworkSceneManager client side notification when it receives a scene hash value that does not exist in its local hash table. (#1828) - Fixed client throws a key not found exception when it times out using UNet or UTP. (#1821) - Fixed network variable updates are no longer limited to 32,768 bytes when NetworkConfig.EnsureNetworkVariableLengthSafety is enabled. The limits are now determined by what the transport can send in a message. (#1811) - Fixed in-scene NetworkObjects get destroyed if a client fails to connect and shuts down the NetworkManager. (#1809) - Fixed user never being notified in the editor that a NetworkBehaviour requires a NetworkObject to function properly. (#1808) - Fixed PlayerObjects and dynamically spawned NetworkObjects not being added to the NetworkClient's OwnedObjects (#1801) - Fixed issue where NetworkManager would continue starting even if the NetworkTransport selected failed. (#1780) - Fixed issue when spawning new player if an already existing player exists it does not remove IsPlayer from the previous player (#1779) - Fixed lack of notification that NetworkManager and NetworkObject cannot be added to the same GameObject with in-editor notifications (#1777) - Fixed parenting warning printing for false positives (#1855)
This commit is contained in:
69
Tests/Runtime/Metrics/ConnectionMetricsTests.cs
Normal file
69
Tests/Runtime/Metrics/ConnectionMetricsTests.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
#if MULTIPLAYER_TOOLS
|
||||
#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using Unity.Multiplayer.Tools.MetricTypes;
|
||||
using Unity.Netcode.TestHelpers.Runtime;
|
||||
using Unity.Netcode.TestHelpers.Runtime.Metrics;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
namespace Unity.Netcode.RuntimeTests.Metrics
|
||||
{
|
||||
[TestFixture(ClientCount.OneClient, HostOrServer.Host)]
|
||||
[TestFixture(ClientCount.TwoClients, HostOrServer.Host)]
|
||||
[TestFixture(ClientCount.OneClient, HostOrServer.Server)]
|
||||
[TestFixture(ClientCount.TwoClients, HostOrServer.Server)]
|
||||
public class ConnectionMetricsTests : NetcodeIntegrationTest
|
||||
{
|
||||
protected override int NumberOfClients => m_ClientCount;
|
||||
|
||||
private int m_ClientCount;
|
||||
|
||||
public enum ClientCount
|
||||
{
|
||||
OneClient = 1,
|
||||
TwoClients,
|
||||
}
|
||||
|
||||
public ConnectionMetricsTests(ClientCount clientCount, HostOrServer hostOrServer)
|
||||
: base(hostOrServer)
|
||||
{
|
||||
m_ClientCount = (int)clientCount;
|
||||
}
|
||||
|
||||
private int GetClientCountForFixture()
|
||||
{
|
||||
return m_ClientCount + ((m_UseHost) ? 1 : 0);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator UpdateConnectionCountOnServer()
|
||||
{
|
||||
var waitForGaugeValues = new WaitForGaugeMetricValues((m_ServerNetworkManager.NetworkMetrics as NetworkMetrics).Dispatcher, NetworkMetricTypes.ConnectedClients);
|
||||
|
||||
yield return waitForGaugeValues.WaitForMetricsReceived();
|
||||
|
||||
var value = waitForGaugeValues.AssertMetricValueHaveBeenFound();
|
||||
Assert.AreEqual(GetClientCountForFixture(), value);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator UpdateConnectionCountOnClient()
|
||||
{
|
||||
foreach (var clientNetworkManager in m_ClientNetworkManagers)
|
||||
{
|
||||
var waitForGaugeValues = new WaitForGaugeMetricValues((clientNetworkManager.NetworkMetrics as NetworkMetrics).Dispatcher, NetworkMetricTypes.ConnectedClients);
|
||||
|
||||
yield return waitForGaugeValues.WaitForMetricsReceived();
|
||||
|
||||
var value = waitForGaugeValues.AssertMetricValueHaveBeenFound();
|
||||
Assert.AreEqual(1, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
3
Tests/Runtime/Metrics/ConnectionMetricsTests.cs.meta
Normal file
3
Tests/Runtime/Metrics/ConnectionMetricsTests.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1845aef61dbb4f2b9d2be9145262ab90
|
||||
timeCreated: 1647023529
|
||||
@@ -39,7 +39,7 @@ namespace Unity.Netcode.RuntimeTests.Metrics
|
||||
|
||||
var networkMessageSentMetricValues = waitForMetricValues.AssertMetricValuesHaveBeenFound();
|
||||
|
||||
// We should have 1 NamedMessage and some potential SnapshotMessage
|
||||
// We should have 1 NamedMessage
|
||||
Assert.That(networkMessageSentMetricValues, Has.Exactly(1).Matches<NetworkMessageEvent>(x => x.Name == nameof(NamedMessage)));
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace Unity.Netcode.RuntimeTests.Metrics
|
||||
yield return waitForMetricValues.WaitForMetricsReceived();
|
||||
|
||||
var networkMessageReceivedValues = waitForMetricValues.AssertMetricValuesHaveBeenFound();
|
||||
// We should have 1 NamedMessage and some potential SnapshotMessage
|
||||
// We should have 1 NamedMessage
|
||||
Assert.That(networkMessageReceivedValues, Has.Exactly(1).Matches<NetworkMessageEvent>(x => x.Name == nameof(NamedMessage)));
|
||||
}
|
||||
|
||||
|
||||
@@ -189,6 +189,76 @@ namespace Unity.Netcode.RuntimeTests.Metrics
|
||||
Assert.AreEqual(1, objectDestroyedSentMetricValues.Select(x => x.BytesCount).Distinct().Count());
|
||||
Assert.That(objectDestroyedSentMetricValues.Select(x => x.BytesCount), Has.All.Not.EqualTo(0));
|
||||
}
|
||||
|
||||
#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
|
||||
[UnityTest]
|
||||
public IEnumerator TrackNetworkObjectCountAfterSpawnOnServer()
|
||||
{
|
||||
SpawnNetworkObject();
|
||||
|
||||
var waitForGaugeValues = new WaitForGaugeMetricValues(ServerMetrics.Dispatcher, NetworkMetricTypes.NetworkObjects);
|
||||
|
||||
yield return s_DefaultWaitForTick;
|
||||
yield return waitForGaugeValues.WaitForMetricsReceived();
|
||||
|
||||
var value = waitForGaugeValues.AssertMetricValueHaveBeenFound();
|
||||
Assert.AreEqual(3, value);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator TrackNetworkObjectCountAfterSpawnOnClient()
|
||||
{
|
||||
SpawnNetworkObject();
|
||||
|
||||
//By default, we have 2 network objects
|
||||
//There's a slight delay between the spawn on the server and the spawn on the client
|
||||
//We want to have metrics when the value is different than the 2 default one to confirm the client has the new value
|
||||
var waitForGaugeValues = new WaitForGaugeMetricValues(ClientMetrics.Dispatcher, NetworkMetricTypes.NetworkObjects, metric => (int)metric != 2);
|
||||
|
||||
yield return waitForGaugeValues.WaitForMetricsReceived();
|
||||
|
||||
var value = waitForGaugeValues.AssertMetricValueHaveBeenFound();
|
||||
Assert.AreEqual(3, value);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator TrackNetworkObjectCountAfterDespawnOnServer()
|
||||
{
|
||||
var objectList = Server.SpawnManager.SpawnedObjectsList;
|
||||
for (int i = objectList.Count - 1; i >= 0; --i)
|
||||
{
|
||||
objectList.ElementAt(i).Despawn();
|
||||
}
|
||||
|
||||
var waitForGaugeValues = new WaitForGaugeMetricValues(ServerMetrics.Dispatcher, NetworkMetricTypes.NetworkObjects);
|
||||
|
||||
yield return s_DefaultWaitForTick;
|
||||
yield return waitForGaugeValues.WaitForMetricsReceived();
|
||||
|
||||
var value = waitForGaugeValues.AssertMetricValueHaveBeenFound();
|
||||
Assert.AreEqual(0, value);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator TrackNetworkObjectCountAfterDespawnOnClient()
|
||||
{
|
||||
var objectList = Server.SpawnManager.SpawnedObjectsList;
|
||||
for (int i = objectList.Count - 1; i >= 0; --i)
|
||||
{
|
||||
objectList.ElementAt(i).Despawn();
|
||||
}
|
||||
|
||||
//By default, we have 2 network objects
|
||||
//There's a slight delay between the spawn on the server and the spawn on the client
|
||||
//We want to have metrics when the value is different than the 2 default one to confirm the client has the new value
|
||||
var waitForGaugeValues = new WaitForGaugeMetricValues(ClientMetrics.Dispatcher, NetworkMetricTypes.NetworkObjects, metric => (int)metric != 2);
|
||||
|
||||
yield return waitForGaugeValues.WaitForMetricsReceived();
|
||||
|
||||
var value = waitForGaugeValues.AssertMetricValueHaveBeenFound();
|
||||
Assert.AreEqual(0, value);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
89
Tests/Runtime/Metrics/PacketLossMetricsTests.cs
Normal file
89
Tests/Runtime/Metrics/PacketLossMetricsTests.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
#if MULTIPLAYER_TOOLS
|
||||
#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using NUnit.Framework;
|
||||
using Unity.Collections;
|
||||
using Unity.Multiplayer.Tools.MetricTypes;
|
||||
using Unity.Netcode.TestHelpers.Runtime;
|
||||
using Unity.Netcode.TestHelpers.Runtime.Metrics;
|
||||
using Unity.Netcode.Transports.UTP;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
namespace Unity.Netcode.RuntimeTests.Metrics
|
||||
{
|
||||
public class PacketLossMetricsTests : NetcodeIntegrationTest
|
||||
{
|
||||
protected override int NumberOfClients => 1;
|
||||
private readonly int m_PacketLossRate = 25;
|
||||
private int m_DropInterval = 5;
|
||||
|
||||
public PacketLossMetricsTests()
|
||||
: base(HostOrServer.Server)
|
||||
{}
|
||||
|
||||
protected override void OnOneTimeSetup()
|
||||
{
|
||||
m_NetworkTransport = NetcodeIntegrationTestHelpers.InstanceTransport.UTP;
|
||||
}
|
||||
|
||||
protected override void OnServerAndClientsCreated()
|
||||
{
|
||||
var clientTransport = (UnityTransport)m_ClientNetworkManagers[0].NetworkConfig.NetworkTransport;
|
||||
clientTransport.SetDebugSimulatorParameters(0, 0, m_PacketLossRate);
|
||||
|
||||
base.OnServerAndClientsCreated();
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator TrackPacketLossAsServer()
|
||||
{
|
||||
var waitForPacketLossMetric = new WaitForGaugeMetricValues((m_ServerNetworkManager.NetworkMetrics as NetworkMetrics).Dispatcher,
|
||||
NetworkMetricTypes.PacketLoss,
|
||||
metric => metric == 0.0d);
|
||||
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
{
|
||||
using (var writer = new FastBufferWriter(sizeof(byte), Allocator.Persistent))
|
||||
{
|
||||
writer.WriteByteSafe(42);
|
||||
m_ServerNetworkManager.CustomMessagingManager.SendNamedMessage("Test", m_ServerNetworkManager.ConnectedClientsIds, writer);
|
||||
}
|
||||
}
|
||||
|
||||
yield return waitForPacketLossMetric.WaitForMetricsReceived();
|
||||
|
||||
var packetLossValue = waitForPacketLossMetric.AssertMetricValueHaveBeenFound();
|
||||
Assert.AreEqual(0d, packetLossValue);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator TrackPacketLossAsClient()
|
||||
{
|
||||
double packetLossRate = m_PacketLossRate/100d;
|
||||
var clientNetworkManager = m_ClientNetworkManagers[0];
|
||||
var waitForPacketLossMetric = new WaitForGaugeMetricValues((clientNetworkManager.NetworkMetrics as NetworkMetrics).Dispatcher,
|
||||
NetworkMetricTypes.PacketLoss,
|
||||
metric => Math.Abs(metric - packetLossRate) < Double.Epsilon);
|
||||
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
{
|
||||
using (var writer = new FastBufferWriter(sizeof(byte), Allocator.Persistent))
|
||||
{
|
||||
writer.WriteByteSafe(42);
|
||||
m_ServerNetworkManager.CustomMessagingManager.SendNamedMessage("Test", m_ServerNetworkManager.ConnectedClientsIds, writer);
|
||||
}
|
||||
}
|
||||
|
||||
yield return waitForPacketLossMetric.WaitForMetricsReceived();
|
||||
|
||||
var packetLossValue = waitForPacketLossMetric.AssertMetricValueHaveBeenFound();
|
||||
Assert.AreEqual(packetLossRate, packetLossValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
3
Tests/Runtime/Metrics/PacketLossMetricsTests.cs.meta
Normal file
3
Tests/Runtime/Metrics/PacketLossMetricsTests.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12e64da4670d49a4a89da38d18e64396
|
||||
timeCreated: 1648133968
|
||||
@@ -1,5 +1,5 @@
|
||||
#if MULTIPLAYER_TOOLS
|
||||
#if MULTIPLAYER_TOOLS_1_0_0_PRE_4
|
||||
#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
|
||||
using System.Collections;
|
||||
using NUnit.Framework;
|
||||
using Unity.Collections;
|
||||
@@ -15,11 +15,7 @@ namespace Unity.Netcode.RuntimeTests.Metrics
|
||||
|
||||
protected override void OnOneTimeSetup()
|
||||
{
|
||||
#if UTP_ADAPTER
|
||||
m_NetworkTransport = NetcodeIntegrationTestHelpers.InstanceTransport.UTP;
|
||||
#else
|
||||
m_NetworkTransport = NetcodeIntegrationTestHelpers.InstanceTransport.SIP;
|
||||
#endif
|
||||
base.OnOneTimeSetup();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#if MULTIPLAYER_TOOLS
|
||||
#if MULTIPLAYER_TOOLS_1_0_0_PRE_4
|
||||
#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -46,11 +46,7 @@ namespace Unity.Netcode.RuntimeTests.Metrics
|
||||
/// </summary>
|
||||
protected override void OnOneTimeSetup()
|
||||
{
|
||||
#if UTP_ADAPTER
|
||||
m_NetworkTransport = NetcodeIntegrationTestHelpers.InstanceTransport.UTP;
|
||||
#else
|
||||
m_NetworkTransport = NetcodeIntegrationTestHelpers.InstanceTransport.SIP;
|
||||
#endif
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
@@ -92,7 +88,7 @@ namespace Unity.Netcode.RuntimeTests.Metrics
|
||||
foreach (var clientGaugeMetricValue in clientGaugeMetricValues)
|
||||
{
|
||||
var rttValue = clientGaugeMetricValue.AssertMetricValueHaveBeenFound();
|
||||
Assert.That(rttValue, Is.GreaterThanOrEqualTo(1f));
|
||||
Assert.That(rttValue, Is.GreaterThanOrEqualTo(1e-3f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user