smoke test cases migration

This commit is contained in:
darapan
2021-05-05 00:37:53 -07:00
parent 70bd3ea0ff
commit f5414050e3
11 changed files with 500 additions and 0 deletions
@@ -307,3 +307,18 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
#)
endif()
## Smoke ##
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
ly_add_pytest(
NAME AutomatedTesting::SmokeTest_Periodic
TEST_SUITE periodic
TEST_SERIAL
PATH ${CMAKE_CURRENT_LIST_DIR}/smoke
TIMEOUT 3600
RUNTIME_DEPENDENCIES
AZ::AssetProcessor
AZ::PythonBindingsExample
Legacy::Editor
AutomatedTesting.GameLauncher
AutomatedTesting.Assets
@@ -0,0 +1,155 @@
"""
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.
Test case ID: LY-123945
Test Case Title: Create Test for UI apps- Editor
URL of the test case: https://jira.agscollab.com/browse/LY-123945
"""
# fmt: off
class Tests():
level_created = ("Level created", "Failed to create level")
entity_found = ("New Entity created in level", "Failed to create New Entity in level")
mesh_added = ("Mesh Component added", "Failed to add Mesh Component")
enter_game_mode = ("Game Mode successfully entered", "Failed to enter in Game Mode")
exit_game_mode = ("Game Mode successfully exited", "Failed to exit in Game Mode")
level_opened = ("Level opened successfully", "Failed to open level")
level_exported = ("Level exported successfully", "Failed to export level")
mesh_removed = ("Mesh Component removed", "Failed to remove Mesh Component")
entity_deleted = ("Entity deleted", "Failed to delete Entity")
level_edits_present = ("Level edits persist after saving", "Failed to save level edits after saving")
# fmt: on
def Editor_NewExistingLevels():
"""
Summary: Perform the below operations on Editor
1) Launch & Close editor
2) Create new level
3) Saving and loading levels
4) Level edits persist after saving
5) Export Level
6) Can switch to play mode (ctrl+g) and exit that
7) Run editor python bindings test
8) Create an Entity
9) Delete an Entity
10) Add a component to an Entity
Expected Behavior:
All operations succeed and do not cause a crash
Test Steps:
1) Launch editor and Create a new level
2) Create a new entity
3) Add Mesh component
4) Verify enter/exit game mode
5) Save, Load and Export level
6) Remove Mesh component
7) Delete entity
8) Open an existing level
9) Create a new entity in an existing level
10) Save, Load and Export an existing level and close editor
Note:
- This test file must be called from the Lumberyard Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
:return: None
"""
import os
import hydra_editor_utils as hydra
from utils import TestHelper as helper
from utils import Report
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.legacy.general as general
import azlmbr.math as math
# 1) Launch editor and Create a new level
helper.init_idle()
test_level_name = "temp_level"
general.create_level_no_prompt(test_level_name, 128, 1, 128, False)
general.idle_wait(2.0)
Report.result(Tests.level_created, general.get_current_level_name() == test_level_name)
# 2) Create a new entity
entity_position = math.Vector3(200.0, 200.0, 38.0)
new_entity = hydra.Entity("Entity1")
new_entity.create_entity(entity_position, [])
test_entity = hydra.find_entity_by_name("Entity1")
Report.result(Tests.entity_found, test_entity.IsValid())
# 3) Add Mesh component
new_entity.add_component("Mesh")
Report.result(Tests.mesh_added, hydra.has_components(new_entity.id, ["Mesh"]))
# 4) Verify enter/exit game mode
helper.enter_game_mode(Tests.enter_game_mode)
helper.exit_game_mode(Tests.exit_game_mode)
# 5) Save, Load and Export level
# Save Level
general.save_level()
# Open Level
general.open_level(test_level_name)
Report.result(Tests.level_opened, general.get_current_level_name() == test_level_name)
# Export Level
general.idle_wait(1.0)
general.export_to_engine()
level_pak_file = os.path.join("AutomatedTesting", "Levels", test_level_name, "level.pak")
Report.result(Tests.level_exported, os.path.exists(level_pak_file))
# 6) Remove Mesh component
new_entity.remove_component("Mesh")
Report.result(Tests.mesh_removed, not hydra.has_components(new_entity.id, ["Mesh"]))
# 7) Delete entity
editor.ToolsApplicationRequestBus(bus.Broadcast, "DeleteEntityById", new_entity.id)
test_entity = hydra.find_entity_by_name("Entity1")
Report.result(Tests.entity_deleted, len(test_entity) == 0)
# 8) Open an existing level
general.open_level(test_level_name)
Report.result(Tests.level_opened, general.get_current_level_name() == test_level_name)
# 9) Create a new entity in an existing level
entity_position = math.Vector3(200.0, 200.0, 38.0)
new_entity_2 = hydra.Entity("Entity2")
new_entity_2.create_entity(entity_position, [])
test_entity = hydra.find_entity_by_name("Entity2")
Report.result(Tests.entity_found, test_entity.IsValid())
# 10) Save, Load and Export an existing level
# Save Level
general.save_level()
# Open Level
general.open_level(test_level_name)
Report.result(Tests.level_opened, general.get_current_level_name() == test_level_name)
entity_id = hydra.find_entity_by_name(new_entity_2.name)
Report.result(Tests.level_edits_present, entity_id == new_entity_2.id)
# Export Level
general.export_to_engine()
level_pak_file = os.path.join("AutomatedTesting", "Levels", test_level_name, "level.pak")
Report.result(Tests.level_exported, os.path.exists(level_pak_file))
if __name__ == "__main__":
import ImportPathHelper as imports
imports.init()
from utils import Report
Report.start_test(Editor_NewExistingLevels)
@@ -0,0 +1,16 @@
"""
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.
"""
def init():
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../automatedtesting_shared')
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../EditorPythonTestTools/editor_python_test_tools')
@@ -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,44 @@
"""
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.
"""
"""
LY-124059 : CLI tool - AssetBuilder
Launch AssetBuilder and Verify the help message
"""
import os
import pytest
import subprocess
import ly_test_tools.environment.process_utils as process_utils
@pytest.mark.parametrize("project", ["AutomatedTesting"])
@pytest.mark.usefixtures("automatic_process_killer")
@pytest.mark.SUITE_smoke
class TestAssetBuilder(object):
@pytest.fixture(autouse=True)
def setup_teardown(self, request):
def teardown():
process_utils.kill_processes_named("AssetBuilder", True)
request.addfinalizer(teardown)
@pytest.mark.test_case_id("LY-124059")
def test_AssetBuilder(self, request, editor, build_directory):
file_path = os.path.join(build_directory, "AssetBuilder")
help_message = "AssetBuilder is part of the Asset Processor"
# Launch AssetBuilder
output = subprocess.run([file_path, "-help"], capture_output=True)
assert (
len(output.stderr) == 0 and output.returncode == 0
), f"Error occurred while launching {file_path}: {output.stderr}"
# Verify help message
assert help_message in str(output.stdout), f"Help Message: {help_message} is not present"
@@ -0,0 +1,43 @@
"""
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.
"""
"""
LY-124061 : CLI tool - AssetProcessorBatch
Launch AssetProcessorBatch and Shutdown AssetProcessorBatch without any crash
"""
# Import builtin libraries
import pytest
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../assetpipeline/")
# Import fixtures
from ap_fixtures.asset_processor_fixture import asset_processor as asset_processor
@pytest.mark.parametrize("project", ["AutomatedTesting"])
@pytest.mark.usefixtures("automatic_process_killer")
@pytest.mark.usefixtures("asset_processor")
@pytest.mark.SUITE_smoke
class TestsAssetProcessorBatchs(object):
@pytest.mark.test_case_id("LY-124061")
def test_AssetProcessorBatch(self, asset_processor):
"""
Test Launching AssetProcessorBatch and verifies that is shuts down without issue
"""
# Create a sample asset root so we don't process every asset for every platform
asset_processor.create_temp_asset_root()
# Launch AssetProcessorBatch, assert batch processing success
result, _ = asset_processor.batch_process()
assert result, "AP Batch failed"
@@ -0,0 +1,46 @@
"""
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.
"""
"""
LY-124062 : CLI tool - AzTestRunner
Launch AzTestRunner and Verify the help message
"""
import os
import pytest
import subprocess
import ly_test_tools.environment.process_utils as process_utils
@pytest.mark.parametrize("project", ["AutomatedTesting"])
@pytest.mark.usefixtures("automatic_process_killer")
@pytest.mark.SUITE_smoke
class TestAzTestRunner(object):
@pytest.fixture(autouse=True)
def setup_teardown(self, request):
def teardown():
process_utils.kill_processes_named("AzTestRunner", True)
request.addfinalizer(teardown)
@pytest.mark.test_case_id("LY-124062")
def test_AzTestRunner(self, request, editor, build_directory):
file_path = os.path.join(build_directory, "AzTestRunner")
help_message = "OKAY Symbol found: AzRunUnitTests"
# Launch AzTestRunner
output = subprocess.run(
[file_path, "AzTestRunner.Tests", "AzRunUnitTests", "--gtest_list_tests"], capture_output=True
)
assert (
len(output.stderr) == 0 and output.returncode == 0
), f"Error occurred while launching {file_path}: {output.stderr}"
# Verify help message
assert help_message in str(output.stdout), f"Help Message: {help_message} is not present"
@@ -0,0 +1,34 @@
"""
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 pytest
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../automatedtesting_shared")
from automatedtesting_shared.base import TestAutomationBase
import ly_test_tools.environment.file_system as file_system
@pytest.mark.SUITE_smoke
@pytest.mark.parametrize("launcher_platform", ["windows_editor"])
@pytest.mark.parametrize("project", ["AutomatedTesting"])
@pytest.mark.parametrize("level", ["temp_level"])
class TestAutomation(TestAutomationBase):
def test_Editor_NewExistingLevels(self, request, workspace, editor, level, project, launcher_platform):
def teardown():
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
request.addfinalizer(teardown)
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
from . import Editor_NewExistingLevels as test_module
self._run_test(request, workspace, editor, test_module)
@@ -0,0 +1,45 @@
"""
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.
"""
"""
LY-124064 : CLI tool - PythonBindingsExample
Launch PythonBindingsExample and Verify the help message
"""
import os
import pytest
import subprocess
import ly_test_tools.environment.process_utils as process_utils
@pytest.mark.parametrize("project", ["AutomatedTesting"])
@pytest.mark.usefixtures("automatic_process_killer")
@pytest.mark.SUITE_smoke
class TestPythonBindingsExample(object):
@pytest.fixture(autouse=True)
def setup_teardown(self, request):
def teardown():
process_utils.kill_processes_named("PythonBindingsExample", True)
request.addfinalizer(teardown)
@pytest.mark.test_case_id("LY-124064")
def test_PythonBindingsExample(self, request, editor, build_directory):
file_path = os.path.join(build_directory, "PythonBindingsExample")
help_message = "--help Prints the help text"
# Launch PythonBindingsExample
output = subprocess.run([file_path, "-help"], capture_output=True)
assert (
len(output.stderr) == 0 and output.returncode == 1
), f"Error occurred while launching {file_path}: {output.stderr}"
# Verify help message
assert help_message in str(output.stdout), f"Help Message: {help_message} is not present"
@@ -0,0 +1,44 @@
"""
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.
"""
"""
LY-124066 : CLI tool - SerializeContextTools
Launch SerializeContextTools and Verify the help message
"""
import os
import pytest
import subprocess
import ly_test_tools.environment.process_utils as process_utils
@pytest.mark.parametrize("project", ["AutomatedTesting"])
@pytest.mark.usefixtures("automatic_process_killer")
@pytest.mark.SUITE_smoke
class TestSerializeContextTools(object):
@pytest.fixture(autouse=True)
def setup_teardown(self, request):
def teardown():
process_utils.kill_processes_named("SerializeContextTools", True)
request.addfinalizer(teardown)
@pytest.mark.test_case_id("LY-124066")
def test_SerializeContextTools(self, request, editor, build_directory):
file_path = os.path.join(build_directory, "SerializeContextTools")
help_message = "Converts a file with an ObjectStream to the new JSON"
# Launch SerializeContextTools
output = subprocess.run([file_path, "-help"], capture_output=True)
assert (
len(output.stderr) == 0 and output.returncode == 0
), f"Error occurred while launching {file_path}: {output.stderr}"
# Verify help message
assert help_message in str(output.stdout), f"Help Message: {help_message} is not present"
@@ -0,0 +1,48 @@
"""
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.
"""
"""
LY-124058: Static tool scripts
Launch Static tool and Verify the help message
"""
import os
import pytest
import subprocess
import sys
def verify_help_message(static_tool):
help_message = ["--help", "show this help message and exit"]
output = subprocess.run([sys.executable, static_tool, "-h"], capture_output=True)
assert (
len(output.stderr) == 0 and output.returncode == 0
), f"Error occurred while launching {static_tool}: {output.stderr}"
# verify help message
for message in help_message:
assert message in str(output.stdout), f"Help Message: {message} is not present"
@pytest.mark.parametrize("project", ["AutomatedTesting"])
@pytest.mark.usefixtures("automatic_process_killer")
@pytest.mark.SUITE_smoke
class TestStatictoolScripts(object):
@pytest.mark.test_case_id("LY-124058")
def test_Statictool_Scripts(self, request, editor):
static_tools = [
os.path.join(editor.workspace.paths.engine_root(), "scripts", "bundler", "gen_shaders.py"),
os.path.join(editor.workspace.paths.engine_root(), "scripts", "bundler", "get_shader_list.py"),
os.path.join(editor.workspace.paths.engine_root(), "scripts", "bundler", "pak_shaders.py"),
]
for tool in static_tools:
verify_help_message(tool)