mirror of
https://github.com/LTTLabsOSS/markbench-tests.git
synced 2026-01-09 22:18:00 -05:00
James round seconds (#129)
this is a ford of jd/harness-fixes that is currently live on the benches, the ONLY thing i changed is im rounding the timestamps to the nearest second please approve --------- Co-authored-by: J-Doiron <139803019+J-Doiron@users.noreply.github.com>
This commit is contained in:
@@ -5,7 +5,7 @@ This test launches a replay of Rocket League. The replay is from RLCS Season 9 N
|
||||
## Prerequisites
|
||||
|
||||
- Python 3.10+
|
||||
- Rocket League installed
|
||||
- Rocket League installed via Epic Games
|
||||
- Keras OCR service
|
||||
- Vgamepad
|
||||
|
||||
@@ -19,4 +19,5 @@ This test launches a replay of Rocket League. The replay is from RLCS Season 9 N
|
||||
report.json
|
||||
- `resolution`: string representing the resolution the test was run at, formatted as "[width]x[height]", e.x. `1920x1080`
|
||||
- `start_time`: number representing a timestamp of the test's start time in milliseconds
|
||||
- `end_time`: number representing a timestamp of the test's end time in milliseconds
|
||||
- `end_time`: number representing a timestamp of the test's end time in milliseconds
|
||||
- `game_version`: number representing the game's current build version
|
||||
@@ -7,7 +7,7 @@ import sys
|
||||
import getpass
|
||||
from pathlib import Path
|
||||
import vgamepad as vg
|
||||
from rocket_league_utils import get_resolution, copy_replay, find_rocketleague_executable, get_args
|
||||
from rocket_league_utils import get_resolution, copy_replay, find_epic_executable, get_args
|
||||
|
||||
sys.path.insert(1, os.path.join(sys.path[0], '..'))
|
||||
|
||||
@@ -21,15 +21,16 @@ from harness_utils.output import (
|
||||
from harness_utils.process import terminate_processes
|
||||
from harness_utils.keras_service import KerasService
|
||||
from harness_utils.artifacts import ArtifactManager, ArtifactType
|
||||
from harness_utils.misc import LTTGamePadDS4
|
||||
from harness_utils.misc import LTTGamePadDS4, find_eg_game_version
|
||||
|
||||
SCRIPT_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
|
||||
LOG_DIRECTORY = os.path.join(SCRIPT_DIRECTORY, "run")
|
||||
USERNAME = getpass.getuser()
|
||||
CONFIG_PATH = Path(f"C:\\Users\\{USERNAME}\\Documents\\My Games\\Rocket League\\TAGame\\Config\\TASystemSettings.ini")
|
||||
PROCESS_NAME = "rocketleague.exe"
|
||||
EXECUTABLE_PATH = find_rocketleague_executable()
|
||||
EXECUTABLE_PATH = find_epic_executable()
|
||||
GAME_ID = "9773aa1aa54f4f7b80e44bef04986cea%3A530145df28a24424923f5828cc9031a1%3ASugar?action=launch&silent=true"
|
||||
gamefoldername = "rocketleague"
|
||||
am = ArtifactManager(LOG_DIRECTORY)
|
||||
gamepad = LTTGamePadDS4()
|
||||
|
||||
@@ -52,6 +53,31 @@ def get_run_game_id_command(game_id: int) -> str:
|
||||
"""Build string to launch game"""
|
||||
return "com.epicgames.launcher://apps/" + str(game_id)
|
||||
|
||||
def camera_cycle(max_attempts=10):
|
||||
"""Continuously looks for a word using kerasService. If not found in the given time, presses a button.
|
||||
|
||||
:param kerasService: Object that has the method look_for_word().
|
||||
:param gamepad: The gamepad object to send button presses.
|
||||
:param word: The word to look for.
|
||||
:param max_attempts: Maximum times to check before stopping.
|
||||
:param check_duration: How long (in seconds) to look for the word before pressing a button.
|
||||
:param button: The gamepad button to press if word is not found.
|
||||
"""
|
||||
for attempt in range(max_attempts):
|
||||
# Try finding the word within check_duration seconds
|
||||
found = kerasService.look_for_word(word="player", attempts=2, interval=0.2)
|
||||
|
||||
if found:
|
||||
return True # Stop checking
|
||||
|
||||
# If not found, press the button once
|
||||
gamepad.single_button_press(button=vg.DS4_BUTTONS.DS4_BUTTON_TRIANGLE)
|
||||
|
||||
# Short delay before rechecking
|
||||
time.sleep(0.5)
|
||||
|
||||
logging.info("Max attempts reached for checking the camera. Did the game load the save?")
|
||||
sys.exit(1) # Word was not found
|
||||
|
||||
def start_game():
|
||||
"""Start the game"""
|
||||
@@ -64,7 +90,7 @@ def run_benchmark():
|
||||
# pylint: disable-msg=too-many-branches
|
||||
"""Run the test!"""
|
||||
copy_replay()
|
||||
setup_start_time = time.time()
|
||||
setup_start_time = int(time.time())
|
||||
start_game()
|
||||
time.sleep(30) # wait for game to load into main menu
|
||||
|
||||
@@ -93,7 +119,7 @@ def run_benchmark():
|
||||
|
||||
gamepad.single_dpad_press(direction=vg.DS4_DPAD_DIRECTIONS.DS4_BUTTON_DPAD_WEST)
|
||||
time.sleep(0.5)
|
||||
gamepad.dpad_press_n_times(direction=vg.DS4_DPAD_DIRECTIONS.DS4_BUTTON_DPAD_NORTH, n=4, pause=0.5)
|
||||
gamepad.dpad_press_n_times(direction=vg.DS4_DPAD_DIRECTIONS.DS4_BUTTON_DPAD_NORTH, n=4, pause=0.8)
|
||||
|
||||
if kerasService.look_for_word(word="esports", attempts=5, interval=0.2):
|
||||
logging.info('Saw esports. Navigating accordingly.')
|
||||
@@ -110,7 +136,7 @@ def run_benchmark():
|
||||
gamepad.single_dpad_press(direction=vg.DS4_DPAD_DIRECTIONS.DS4_BUTTON_DPAD_SOUTH)
|
||||
time.sleep(0.5)
|
||||
|
||||
gamepad.dpad_press_n_times(direction=vg.DS4_DPAD_DIRECTIONS.DS4_BUTTON_DPAD_SOUTH, n=2, pause=0.5)
|
||||
gamepad.dpad_press_n_times(direction=vg.DS4_DPAD_DIRECTIONS.DS4_BUTTON_DPAD_SOUTH, n=2, pause=0.8)
|
||||
time.sleep(0.5)
|
||||
gamepad.single_button_press(button=vg.DS4_BUTTONS.DS4_BUTTON_CROSS)
|
||||
time.sleep(1)
|
||||
@@ -136,7 +162,7 @@ def run_benchmark():
|
||||
|
||||
gamepad.single_button_press(button=vg.DS4_BUTTONS.DS4_BUTTON_CROSS)
|
||||
|
||||
setup_end_time = time.time()
|
||||
setup_end_time = int(time.time())
|
||||
elapsed_setup_time = round(setup_end_time - setup_start_time, 2)
|
||||
logging.info("Harness setup took %f seconds", elapsed_setup_time)
|
||||
|
||||
@@ -146,20 +172,23 @@ def run_benchmark():
|
||||
sys.exit(1)
|
||||
|
||||
gamepad.single_button_press(button=vg.DS4_BUTTONS.DS4_BUTTON_CROSS)
|
||||
time.sleep(0.5)
|
||||
time.sleep(0.8)
|
||||
gamepad.single_dpad_press(direction=vg.DS4_DPAD_DIRECTIONS.DS4_BUTTON_DPAD_WEST)
|
||||
time.sleep(0.5)
|
||||
gamepad.button_press_n_times(button=vg.DS4_BUTTONS.DS4_BUTTON_TRIANGLE, n=5, pause=0.5)
|
||||
time.sleep(0.8)
|
||||
camera_cycle()
|
||||
time.sleep(0.5)
|
||||
gamepad.single_button_press(button=vg.DS4_BUTTONS.DS4_BUTTON_CROSS)
|
||||
logging.info("Benchmark started. Waiting for completion.")
|
||||
time.sleep(4)
|
||||
test_start_time = time.time()
|
||||
test_start_time = int(time.time())
|
||||
|
||||
# wait for benchmark to complete
|
||||
time.sleep(359)
|
||||
|
||||
test_end_time = time.time()
|
||||
if kerasService.wait_for_word(word="turbopolsa", timeout=10, interval=1) is None:
|
||||
logging.info("Couldn't turbopolsa on the field. Did the benchmark play all the way through?")
|
||||
sys.exit(1)
|
||||
test_end_time = int(time.time())
|
||||
time.sleep(2)
|
||||
elapsed_test_time = round((test_end_time - test_start_time), 2)
|
||||
logging.info("Benchmark took %f seconds", elapsed_test_time)
|
||||
@@ -184,7 +213,7 @@ def run_benchmark():
|
||||
|
||||
time.sleep(1)
|
||||
logging.info("Navigating to the Video tab.")
|
||||
gamepad.button_press_n_times(button=vg.DS4_BUTTONS.DS4_BUTTON_SHOULDER_RIGHT, n=4, pause=0.5)
|
||||
gamepad.button_press_n_times(button=vg.DS4_BUTTONS.DS4_BUTTON_SHOULDER_RIGHT, n=4, pause=0.8)
|
||||
time.sleep(1)
|
||||
|
||||
if kerasService.look_for_word(word="window", attempts=10, interval=1) is None:
|
||||
@@ -209,7 +238,8 @@ try:
|
||||
report = {
|
||||
"resolution": format_resolution(width, height),
|
||||
"start_time": seconds_to_milliseconds(start_time),
|
||||
"end_time": seconds_to_milliseconds(end_time)
|
||||
"end_time": seconds_to_milliseconds(end_time),
|
||||
"game_version": find_eg_game_version(gamefoldername)
|
||||
}
|
||||
|
||||
write_report_json(LOG_DIRECTORY, "report.json", report)
|
||||
|
||||
@@ -6,6 +6,7 @@ import logging
|
||||
import re
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
import json
|
||||
|
||||
USERNAME = getpass.getuser()
|
||||
SCRIPT_DIRECTORY = Path(__file__).resolve().parent
|
||||
@@ -61,8 +62,8 @@ def copy_replay() -> None:
|
||||
raise err
|
||||
|
||||
|
||||
def find_rocketleague_executable() -> any:
|
||||
"""Get path to rocket league executable"""
|
||||
def find_epic_executable() -> any:
|
||||
"""Get path to Epic Games Executable"""
|
||||
reg_path = r'Software\Epic Games\EOS'
|
||||
try:
|
||||
registry_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, reg_path, 0,
|
||||
@@ -70,6 +71,5 @@ def find_rocketleague_executable() -> any:
|
||||
value, _ = winreg.QueryValueEx(registry_key, "ModSdkCommand")
|
||||
winreg.CloseKey(registry_key)
|
||||
return value
|
||||
except OSError as err:
|
||||
logging.error("Could not find executable path")
|
||||
raise err
|
||||
except OSError:
|
||||
return None
|
||||
Reference in New Issue
Block a user