Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
@@ -0,0 +1,59 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
A sanity test for the built-in fixtures.
Launch the windows launcher attached to the currently installed instance.
"""
import logging
import pytest
import ly_test_tools
import ly_test_tools.launchers.launcher_helper as launcher_helper
import ly_test_tools.builtin.helpers as helpers
import ly_test_tools.environment.process_utils as process_utils
import ly_test_tools.environment.waiter as waiter
pytestmark = pytest.mark.SUITE_smoke
logger = logging.getLogger(__name__)
# Note: For device testing, device ids must exist in ~/ly_test_tools/devices.ini, see README.txt for more info.
@pytest.mark.parametrize("project", ["AutomatedTesting"])
class TestAutomatedTestingProject(object):
def test_StartGameLauncher_Sanity(self, project):
process_utils.kill_processes_named(names=process_utils.LY_PROCESS_KILL_LIST, ignore_extensions=True)
try:
workspace = helpers.create_builtin_workspace(project=project)
launcher = launcher_helper.create_launcher(workspace)
launcher.args.extend(['-NullRenderer', '-BatchMode'])
with launcher.start():
waiter.wait_for(lambda: process_utils.process_exists(f"{project}.GameLauncher.exe", ignore_extensions=True))
finally:
process_utils.kill_processes_named(names=process_utils.LY_PROCESS_KILL_LIST, ignore_extensions=True)
@pytest.mark.skipif(not ly_test_tools.WINDOWS, reason="Editor currently only functions on Windows")
def test_StartEditor_Sanity(self, project):
process_utils.kill_processes_named(names=process_utils.LY_PROCESS_KILL_LIST, ignore_extensions=True)
try:
workspace = helpers.create_builtin_workspace(project=project)
editor = launcher_helper.create_editor(workspace)
editor.args.extend(['-NullRenderer', '-autotest_mode'])
with editor.start():
waiter.wait_for(lambda: process_utils.process_exists("Editor", ignore_extensions=True))
finally:
process_utils.kill_processes_named(names=process_utils.LY_PROCESS_KILL_LIST, ignore_extensions=True)
@@ -0,0 +1,47 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
import os
import subprocess
import pytest
import ly_test_tools.environment.process_utils as process_utils
import ly_test_tools.environment.waiter as waiter
from ly_test_tools import WINDOWS
if WINDOWS:
pytestmark = pytest.mark.SUITE_smoke
else:
pytestmark = pytest.mark.skipif(not WINDOWS, reason="Only runs on Windows")
class TestSubprocessCheckOutputWrapper(object):
def test_KillWindowsProgram_WindowsProgramStarted_KilledSuccessfully(self):
windows_program = 'timeout.exe'
windows_directory = os.environ.get('windir')
command = [
os.path.join(f'{windows_directory}', 'System32', f'{windows_program}'),
'/T', # Timeout flag
'4', # 4 seconds
]
def process_killed():
return not process_utils.process_exists(windows_program, ignore_extensions=True)
assert os.path.exists(command[0]), (
f'The {windows_program} executable does not exist at: {command[0]}'
)
with subprocess.Popen(command, creationflags=subprocess.CREATE_NEW_CONSOLE) as process:
if process_utils.process_exists(windows_program, ignore_extensions=True):
process_utils.kill_process_with_pid(process.pid)
waiter.wait_for(process_killed, timeout=2) # Raises exception if the process is alive.
@@ -0,0 +1,75 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Regression tests for the built-in fixtures.
"""
import logging
import os
import pytest
import ly_test_tools.environment.process_utils as process_utils
import ly_test_tools.environment.file_system as file_system
import ly_test_tools.environment.waiter as waiter
from ly_test_tools import WINDOWS
pytestmark = pytest.mark.SUITE_periodic
logger = logging.getLogger(__name__)
@pytest.fixture(scope="function")
def editor_closed_checker(request):
"""
Verifies that the Editor and AP processes have been terminated when the test ends.
"""
test_name = request.node
yield
# The Editor fixture should've terminated the Editor and the AP processes
processes = ['Editor', 'AssetProcessor']
processes_found = []
for process in processes:
if process_utils.process_exists(process, True):
processes_found.append(f"Process '{process}' should have been terminated by the fixture after the test"
f" {test_name} finished.")
process_utils.kill_processes_named(process, True)
assert not processes_found, f"Editor fixture unexpectedly did not clean up open processes, processes still open: {processes_found}"
@pytest.fixture(scope="function")
def log_cleaner(workspace):
"""
Removes Game and Editor logs before test execution
"""
logs = ['Game.log', 'Editor.log']
for log in logs:
log_file = os.path.join(workspace.paths.project_log(), log)
if os.path.exists(log_file):
file_system.delete([log_file], True, False)
@pytest.mark.usefixtures("automatic_process_killer")
@pytest.mark.usefixtures("log_cleaner")
@pytest.mark.parametrize("project", ["AutomatedTesting"])
@pytest.mark.skipif(not WINDOWS, reason="Editor currently only functions on Windows")
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
class TestEditorFixture(object):
def test_EditorNotClosed_FixtureStopsProcesses(self, editor_closed_checker, editor, launcher_platform):
# Set autotest mode and disable GPU usage
editor.args.extend(['-NullRenderer', '-autotest_mode'])
log_file = os.path.join(editor.workspace.paths.project_log(), "Editor.log")
editor.start()
waiter.wait_for(lambda: os.path.exists(log_file), timeout=180) # time out increased due to bug SPEC-3175
assert editor.is_alive()
# This test doesn't call editor.stop() explicitly. Instead it uses the editor_closed_checker fixture to verify
# that the editor fixture closes the editor and AP processes.
@@ -0,0 +1,52 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
import filecmp
import os
import pytest
pytestmark = pytest.mark.SUITE_smoke
class TestLySettings(object):
@pytest.mark.parametrize("project", ["AutomatedTesting"])
@pytest.mark.parametrize("wait_for_connect", [1234, 4567])
def test_BootstrapSettings_BackupModifyRestore_SettingsMatch(self, workspace, wait_for_connect):
backup_path = workspace.tmp_path
# create backup
workspace.settings.backup_bootstrap_settings(backup_path)
# verify files match
bootstrap_settings = workspace.paths.bootstrap_config_file()
bootstrap_settings_backup = os.path.join(backup_path, '{}.bak'.format(os.path.basename(bootstrap_settings)))
assert os.path.exists(bootstrap_settings), "Bootstrap settings file does not exist"
assert os.path.exists(bootstrap_settings_backup), "Bootstrap settings backup does not exist"
assert filecmp.cmp(bootstrap_settings, bootstrap_settings_backup), "Bootstrap settings and backup do not match"
# modify settings
workspace.settings.modify_bootstrap_setting('remote_filesystem', 0)
workspace.settings.modify_bootstrap_setting('wait_for_connect', wait_for_connect)
workspace.settings.modify_bootstrap_setting('remote_ip', '0.36.27.18')
workspace.settings.modify_bootstrap_setting('additional_setting', 'value1')
# verify files are different
assert not filecmp.cmp(bootstrap_settings, bootstrap_settings_backup), "Modified bootstrap settings and backup" \
" are equal, they should be different"
# restore backup
workspace.settings.restore_bootstrap_settings(backup_path)
# verify files match
assert filecmp.cmp(bootstrap_settings, bootstrap_settings_backup), "Restored bootstrap settings and backup " \
"are different, they should be equal"