TestSuite_Sandbox.py 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. import pytest
  7. import os
  8. import sys
  9. from ly_test_tools.o3de.editor_test import EditorTestSuite, EditorSingleTest
  10. sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../automatedtesting_shared')
  11. from ly_test_tools.environment import process_utils
  12. from ly_test_tools.launchers import launcher_helper
  13. from ly_test_tools.log.log_monitor import LogMonitor
  14. import ly_test_tools.environment.waiter as waiter
  15. # Saves the level cache folder.
  16. # These artifacts will be saved in the test results so developers can access the level assets
  17. # to debug should the test ever fail.
  18. def save_multiplayer_level_cache_folder_artifact(workspace, multiplayer_level):
  19. level_cache_folder_path = os.path.join(workspace.paths.platform_cache(), "levels", "multiplayer", multiplayer_level)
  20. if os.path.exists(level_cache_folder_path):
  21. workspace.artifact_manager.save_artifact(level_cache_folder_path)
  22. else:
  23. pytest.fail(f"Failed to find level asset cache for '{multiplayer_level}', located here: '{level_cache_folder_path}'! Make sure AssetProcessor successfully built the level.")
  24. @pytest.mark.SUITE_sandbox
  25. @pytest.mark.parametrize("project", ["AutomatedTesting"])
  26. @pytest.mark.parametrize("launcher_platform", ['windows_editor'])
  27. class TestAutomation(EditorTestSuite):
  28. class test_Multiplayer_AutoComponent_NetworkInput(EditorSingleTest):
  29. from .tests import Multiplayer_AutoComponent_NetworkInput as test_module
  30. @classmethod
  31. def setup(cls, instance, request, workspace):
  32. save_multiplayer_level_cache_folder_artifact(workspace, "autocomponent_networkinput")
  33. @pytest.mark.xfail(reason="GHI #9869: Test periodically fails")
  34. class test_Multiplayer_AutoComponent_RPC(EditorSingleTest):
  35. from .tests import Multiplayer_AutoComponent_RPC as test_module
  36. @classmethod
  37. def setup(cls, instance, request, workspace):
  38. save_multiplayer_level_cache_folder_artifact(workspace, "autocomponent_rpc")
  39. class test_Multiplayer_SimpleNetworkLevelEntity(EditorSingleTest):
  40. from .tests import Multiplayer_SimpleNetworkLevelEntity as test_module
  41. @classmethod
  42. def setup(cls, instance, request, workspace):
  43. save_multiplayer_level_cache_folder_artifact(workspace, "simplenetworklevelentity")
  44. def test_Multiplayer_SimpleGameServerLauncher_ConnectsSuccessfully(self, workspace, launcher_platform, crash_log_watchdog):
  45. unexpected_lines = []
  46. expected_lines = ["New outgoing connection to remote address:"]
  47. halt_on_unexpected = False
  48. timeout = 180
  49. # Start the AutomatedTesting.ServerLauncher.exe in hosting mode, no rendering mode, and wait for it to exist
  50. server_launcher = launcher_helper.create_server_launcher(workspace)
  51. server_launcher.args.extend(['+host', '-rhi=Null'])
  52. server_launcher.start()
  53. waiter.wait_for(lambda: process_utils.process_exists(f"AutomatedTesting.ServerLauncher.exe", ignore_extensions=True))
  54. # Start the AutomatedTesting.GameLauncher.exe in client mode, no rendering mode, and wait for it to exist
  55. game_launcher = launcher_helper.create_game_launcher(workspace)
  56. game_launcher.args.extend(['+connect', '-rhi=Null'])
  57. game_launcher.start()
  58. waiter.wait_for(lambda: process_utils.process_exists(f"AutomatedTesting.GameLauncher.exe", ignore_extensions=True))
  59. # Verify that the GameLauncher.exe was able to connect to the ServerLauncher.exe by checking the logs
  60. game_launcher_log_file = os.path.join(game_launcher.workspace.paths.project_log(), 'Game.log')
  61. game_launcher_log_monitor = LogMonitor(game_launcher, game_launcher_log_file)
  62. game_launcher_log_monitor.monitor_log_for_lines(expected_lines, unexpected_lines, halt_on_unexpected, timeout)
  63. process_utils.kill_processes_named("AssetProcessor.exe", ignore_extensions=True)