Skip to content

test: manual connection approval to fully automated connection approval testing - #839

Merged
NoelStephensUnity merged 57 commits into
developfrom
test/multi-instance-connection-approval
May 20, 2021
Merged

test: manual connection approval to fully automated connection approval testing#839
NoelStephensUnity merged 57 commits into
developfrom
test/multi-instance-connection-approval

Conversation

@NoelStephensUnity

@NoelStephensUnity NoelStephensUnity commented May 17, 2021

Copy link
Copy Markdown
Member

This is the conversion of the manual connection approval test to an automated unit test using the MultiInstanceHelpers class.
This is dependent upon the changes in PR-841.
The reference Jira Ticket for this is MTT-778

NoelStephensUnity and others added 22 commits May 13, 2021 16:44
This is the first pass version with a duplicated MultiInstanceHelper.
This includes SIPTransport updates that prevent issues with multiple SIPTransport unit tests as the S_Server was never getting reset.  So, upon the host-server disconnecting it resets the value back to null so the next unit test can initialize the SIPTransport again.

This includes a fix for unit tests that may result in the SnapshotSystem attempting to send before m_NetworkManager is set.
fixing the spaces.
Removing the temporary MultiInstanceHelpers class and migrating the changes over to the original MultiInstanceHelpers class.

Renamed the UnityTest to ManualRpcTestsAutomated.
Including the assembly definition file... :)
Increasing the total number of clients to 10.
1 Host and 9 clients.
Updating comment to reflect the proper number of clients (changed from 7 and 1 host to 9 and 1 host)
Adding the ability to run this same test under different conditions.
This pass provides the ability to specify the number of clients (always will be a host) and whether it will be using batched RPCs or not.
Creating a HybridScripts folder to distinguish between manual tests that have yet to be automated and manual tests that can be run in both a unit test and as a manual test.
Reverting change to snapshot system.
Condensed assembly definition per suggestion by Fatih.
This tests connection approval, approval failure, and player prefab overriding via the connection approval process.
@NoelStephensUnity
NoelStephensUnity marked this pull request as ready for review May 17, 2021 20:28
Buffer.BlockCopy(data.Array, data.Offset, copy, 0, data.Count);

m_Clients[clientId].IncomingBuffer.Enqueue(new Event
if (m_LocalConnection != null)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a player is disconnected m_LocalConnection becomes null, but can still be called since the NetworkManager is not notified of the client disconnecting. This resolves this issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this "skip if null" logic might simply make us blind to some issues happening in the future.
please log a warning on the else branch at least.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TwoTenPvP Please review the above changes.
SIPTransport.DisconnectLocalClient sets m_LocalConnection to null but never notifies the relative NetworkManager that the client has disconnected which can cause other systems (i.e. SnapShotSystem) to cause a barrage of exceptions when trying to send snapshots from a disconnected client.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is meant to notify all peers that it disconnected.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why this would happen or what's going on behind the scenes but I still want to see a warning log printed so that a dev wouldn't be blind and execution wouldn't fail silently. do you guys think my request is still reasonable?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me DM you on this... there are other things to consider here.

public override NetworkEvent PollEvent(out ulong clientId, out NetworkChannel channel, out ArraySegment<byte> payload, out float receiveTime)
{
if (m_LocalConnection.IncomingBuffer.Count == 0)
if (m_LocalConnection != null)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a player is disconnected m_LocalConnection becomes null, but can still be called since the NetworkManager is not notified of the client disconnecting. The resolution for this was to return back NetworkEvent.Nothing for the still running NetworkManager that is attempting to poll the SIPTransport for the client in question.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to above, I'd warn dev here and even expect them to look at their call-stack & code-path when this happens.
please put something into the else branch.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TwoTenPvP Please review the above changes.
SIPTransport.DisconnectLocalClient sets m_LocalConnection to null but never notifies the relative NetworkManager that the client has disconnected which can cause other systems (i.e. SnapShotSystem) to cause a barrage of exceptions when trying to send snapshots from a disconnected client.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

This is no longer needed.
keeping the same CR spacing as the original version.
Minor adjustment to see if this makes a difference on Ubuntu
increasing the total frame count as it looks like Ubuntu takes a bit longer to complete these tests.
Fixing a few issues that I think were impacting the Ubuntu builds.
Removing the "test clients failed to connection via approval" to see if this is causing the issue.
Checking to see if Rpc Manual tests run fine with these changes.
Assuring the  m_ContinueToRun is set to true when setting the test mode (could be that the Start method has yet to be invoked by the time it checks.
Adding time as a sanity check...
Adding a time sanity check...
removing network managers from the list
increased wait frame count
More tweaks for Ubuntu
Check for key before accessing.
Running some additional information gathering tests regarding frame rates:.
gathering additional information.
Running one more test with the Application.targetFrameRate being set.
Did some final clean up on the code to prepare for review.
Cleaned up/added comments.

Added an Application.targetFrameRate check that will assure this test, for all platforms, runs at the same frame update rate.
With all of the fixes in place, going to test connection approval failure one last time to see if the recent changes made helps to fix the issue with failed clients.
Adding the same target frame rate adjustment to assure a consistent frame update rate between platforms.

@0xFA11 0xFA11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to go! 🚀

@NoelStephensUnity
NoelStephensUnity merged commit e7d8c0a into develop May 20, 2021
@NoelStephensUnity
NoelStephensUnity deleted the test/multi-instance-connection-approval branch May 20, 2021 16:06
SamuelBellomo added a commit that referenced this pull request May 21, 2021
…player-object-get

* develop:
  test: manual connection approval to fully automated connection approval testing (#839)
  test: manual rpc tests to automated fixed revision (#841)
  fix: CleanDiffedSceneObjects was not clearing PendingSoftSyncObjects  (#834)
  feat: NetworkTransform now uses NetworkVariables instead of RPCs (#826)
  fix: gracefully handle exceptions in an RPC invoke (#846)
  fix: Fixing utp license file for legal (#843)
  ci: enable standards check on UTP too (#837)
  refactor: NetworkBehaviour.NetworkObject no longer throws an exception (#838)
  fix: revert #830 (#840)
  test: converting the manual rpc tests over to an automated unit test (#830)

# Conflicts:
#	com.unity.multiplayer.mlapi/Tests/Runtime/MultiInstance/MultiInstanceHelpers.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants