Skip to content

refactor!: Unified Shutdown #1108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Sep 2, 2021
Merged

refactor!: Unified Shutdown #1108

merged 18 commits into from
Sep 2, 2021

Conversation

TwoTenPvP
Copy link
Contributor

BREAKING CHANGE: NetworkManager.StopX is replaced with NetworkManager.Shutdown

BREAKING CHANGE: NetworkManager.StopX is replaced with NetworkManager.Shutdown
@TwoTenPvP
Copy link
Contributor Author

MTT-983

{
var disconnectedIds = new HashSet<ulong>();

//Don't know if I have to disconnect the clients. I'm assuming the NetworkTransport does all the cleaning on shtudown. But this way the clients get a disconnect message from server (so long it does't get lost)
Copy link
Contributor

@0xFA11 0xFA11 Aug 31, 2021

Choose a reason for hiding this comment

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

some grammar mistakes there and also in the summary section.

++ I'd like to get @andrews-unity quick thoughts about this PR :)

Copy link
Contributor

Choose a reason for hiding this comment

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

(also the comment should not exist and merged in, probably)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved what was in the old Stop methods, I will clean it up a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the comment should continue to exist. Because it's a quirk of the current transport implementation. Perhaps rephrased.

Copy link
Contributor

@andrews-unity andrews-unity left a comment

Choose a reason for hiding this comment

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

So unfortunately given the way StartHost/Client/Server is setup it calls Initialize which assumes that Shutdown is called which means that we have code that assumes that this PR is doing what its doing.

So for me I don't think we have much choice with the current way things are to not have this PR without potentially having errors thrown etc..

public class StartStopTests
{
[Test]
public void TestStopAndRestartForExceptions()
Copy link
Contributor

Choose a reason for hiding this comment

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

You're testing between 2 and (arguably) 12 things in this test.

  • Are you trying to test IsServer, IsClient, IsHost are set properly for StartServer? If so, it should be its own test (asserts)
  • Are you trying to test IsServer, IsClient, IsHost are set to false after Shutdown? If so, it should be its own test (asserts)
  • Are you trying to test the flags are set properly on restart? If so, its own test (asserts)
  • Are you trying to test multiple shutdowns don't throw an exception (as the test is named)? If so, should be its own test (asserts)
  • Are you trying to ensure other values are properly set/cleared during a shutdown? Separate test... etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, for this type of code, consider using a multi assert pattern (though be careful not to abuse the purpose of this)

https://docs.nunit.org/articles/nunit/writing-tests/assertions/multiple-asserts.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will update!

Copy link
Contributor

@JesseOlmer JesseOlmer left a comment

Choose a reason for hiding this comment

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

lgtm

}

[Test]
public void TestStopAndRestartForExceptions()
Copy link
Contributor

Choose a reason for hiding this comment

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

These look much better, good job!

nit: The team just had a conversation about this, and still isn't aligned quite yet so feel free to disregard, but I'm a fan of more descriptive test names... e.g. either SUTShouldDoExpectedThingWhenSpecificState or SUT_SpecificState_ExpectedResult so in this case it might be something like NetworkManagerShouldNotThrowExceptionsWhenRestarted, or NetworkManager_StartAfterShutdown_DoesNotThrow

@0xFA11 0xFA11 enabled auto-merge (squash) September 2, 2021 15:43
@TwoTenPvP TwoTenPvP disabled auto-merge September 2, 2021 15:46
@TwoTenPvP TwoTenPvP enabled auto-merge (squash) September 2, 2021 15:46
@TwoTenPvP TwoTenPvP merged commit 1bbe95f into develop Sep 2, 2021
@TwoTenPvP TwoTenPvP deleted the unify-shutdown2 branch September 2, 2021 15:57
SamuelBellomo added a commit that referenced this pull request Sep 3, 2021
…hub.com:Unity-Technologies/com.unity.multiplayer.mlapi into sam/feature/interpolation-for-network-transform

* 'sam/feature/interpolation-for-network-transform' of github.com:Unity-Technologies/com.unity.multiplayer.mlapi:
  fix: networkscenemanager not releasing buffers from pool (#1132)
  test: fixed-length strings in netvars (#1119)
  fix: snapshot system. last fixes for release (#1129)
  refactor!: Unified Shutdown (#1108)
  chore: Fill out unity project for integration test project (#1128)
  feat: make ServerRpc ownership check an error log instead of warning log (#1126)
mollstam pushed a commit to Keepsake-Games/com.unity.netcode.gameobjects that referenced this pull request Feb 13, 2023
BREAKING CHANGE: NetworkManager.StopX is replaced with NetworkManager.Shutdown
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.

4 participants