benchmark_runner_periodic_suite.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 logging
  7. import os
  8. import subprocess
  9. import pytest
  10. import ly_test_tools.environment.process_utils as process_utils
  11. import ly_test_tools.launchers.platforms.base
  12. from ly_test_tools.benchmark.data_aggregator import BenchmarkDataAggregator
  13. logger = logging.getLogger(__name__)
  14. class AtomSampleViewerException(Exception):
  15. """Custom Exception class for AtomSampleViewer tests."""
  16. pass
  17. @pytest.mark.parametrize('launcher_platform', ['windows'])
  18. @pytest.mark.parametrize("project", ["AtomSampleViewer"])
  19. @pytest.mark.parametrize('rhi', ['dx12', 'vulkan'])
  20. @pytest.mark.usefixtures("clean_atomsampleviewer_logs", "atomsampleviewer_log_monitor")
  21. class TestPerformanceBenchmarksPeriodicSuite:
  22. def test_PerformanceBenchmarkPeriodicSuite(self, request, workspace, launcher_platform, rhi, atomsampleviewer_log_monitor):
  23. # Script call setup.
  24. benchmark_script = '_AutomatedPeriodicBenchmarkSuite_.bv.lua'
  25. benchmark_script_path = os.path.join(workspace.paths.project(), 'Scripts', benchmark_script)
  26. if not os.path.exists(benchmark_script_path):
  27. raise AtomSampleViewerException(f'Test script does not exist in path: {benchmark_script_path}')
  28. cmd = os.path.join(workspace.paths.build_directory(),
  29. 'AtomSampleViewerStandalone.exe '
  30. f'--project-path={workspace.paths.project()} '
  31. f'--rhi {rhi} '
  32. f'--runtestsuite scripts/{benchmark_script}c '
  33. '--exitontestend')
  34. def teardown():
  35. process_utils.kill_processes_named(['AssetProcessor', 'AtomSampleViewerStandalone'], ignore_extensions=True)
  36. request.addfinalizer(teardown)
  37. # Execute test.
  38. process_utils.safe_check_call(cmd, stderr=subprocess.STDOUT, encoding='UTF-8', shell=True)
  39. try:
  40. expected_lines = ["Script: Capturing complete."]
  41. atomsampleviewer_log_monitor.monitor_log_for_lines(expected_lines, timeout=210)
  42. aggregator = BenchmarkDataAggregator(workspace, logger, 'periodic')
  43. aggregator.upload_metrics(rhi)
  44. except ly_test_tools.log.log_monitor.LogMonitorException as e:
  45. raise AtomSampleViewerException(f'Data capturing did not complete in time for RHI {rhi}, got error: {e}')