Multiplayer_SimpleNetworkLevelEntity.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. """
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. """
  6. # Test Case Title : Check that level entities with network bindings are properly replicated.
  7. # Note: This test should be ran on a fresh editor run; some bugs with spawnables occur only on the first editor play-mode.
  8. # fmt: off
  9. class TestSuccessFailTuples():
  10. enter_game_mode = ("Entered game mode", "Failed to enter game mode")
  11. exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
  12. find_network_player = ("Found network player", "Couldn't find network player")
  13. # fmt: on
  14. def Multiplayer_SimpleNetworkLevelEntity():
  15. r"""
  16. Summary:
  17. Test to make sure that network entities in a level function and are replicated to clients as expected
  18. Level Description:
  19. - Static
  20. 1. NetLevelEntity. This is a networked entity which has a script attached which prints logs to ensure it's replicated.
  21. Expected Outcome:
  22. We should see logs stating that the net-sync'd level entity exists on both server and client.
  23. :return:
  24. """
  25. import azlmbr.legacy.general as general
  26. from editor_python_test_tools.utils import Report
  27. from editor_python_test_tools.utils import Tracer
  28. from editor_python_test_tools.utils import TestHelper as helper
  29. level_name = "SimpleNetworkLevelEntity"
  30. helper.init_idle()
  31. # 1) Open Level
  32. helper.open_level("Multiplayer", level_name)
  33. general.set_cvar_integer('editorsv_port', 33455)
  34. with Tracer() as section_tracer:
  35. # 2) Enter game mode
  36. helper.multiplayer_enter_game_mode(TestSuccessFailTuples.enter_game_mode)
  37. # 3) Make sure the network player was spawned
  38. player_id = general.find_game_entity("Player")
  39. Report.critical_result(TestSuccessFailTuples.find_network_player, player_id.IsValid())
  40. # 4) Check the editor logs for network spawnable errors
  41. ATTEMPTING_INVALID_NETSPAWN_WAIT_TIME_SECONDS = 0.0 # The editor will try to net-spawn its networked level entity before it's even a client. Make sure this didn't happen.
  42. helper.fail_if_log_line_found('NetworkEntityManager', "RequestNetSpawnableInstantiation: Requested spawnable Root.network.spawnable doesn't exist in the NetworkSpawnableLibrary. Please make sure it is a network spawnable", section_tracer.errors, ATTEMPTING_INVALID_NETSPAWN_WAIT_TIME_SECONDS)
  43. # 5) Ensure the script graph attached to the level entity is running on the server
  44. SCRIPTGRAPH_ENABLED_WAIT_TIME_SECONDS = 0.25
  45. helper.succeed_if_log_line_found('EditorServer', "Script: SimpleNetworkLevelEntity: On Graph Start", section_tracer.prints, SCRIPTGRAPH_ENABLED_WAIT_TIME_SECONDS)
  46. # Exit game mode
  47. helper.exit_game_mode(TestSuccessFailTuples.exit_game_mode)
  48. if __name__ == "__main__":
  49. from editor_python_test_tools.utils import Report
  50. Report.start_test(Multiplayer_SimpleNetworkLevelEntity)