Merge pull request #570 from aws-lumberyard-dev/smoke_migration_branch

smoke test cases migration
main
Sean Sweeney 5 years ago committed by GitHub
commit aa193d9943
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -400,3 +400,21 @@ 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
TEST_SUITE smoke
TEST_SERIAL
PATH ${CMAKE_CURRENT_LIST_DIR}/smoke
TIMEOUT 1500
RUNTIME_DEPENDENCIES
AZ::AssetProcessor
AZ::PythonBindingsExample
Legacy::Editor
AutomatedTesting.GameLauncher
AutomatedTesting.Assets
COMPONENT
Smoke
)
endif()

@ -0,0 +1,147 @@
"""
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 Title: Create Test for UI apps- Editor
"""
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")
def Editor_NewExistingLevels_Works():
"""
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 editor_python_test_tools.hydra_editor_utils as hydra
from editor_python_test_tools.utils import TestHelper as helper
from editor_python_test_tools.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)
helper.wait_for_condition(lambda: general.get_current_level_name() == test_level_name, 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.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__":
from editor_python_test_tools.utils import Report
Report.start_test(Editor_NewExistingLevels_Works)

@ -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,32 @@
"""
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.
CLI tool - AssetBuilder
Launch AssetBuilder and Verify the help message
"""
import os
import pytest
import subprocess
@pytest.mark.SUITE_smoke
class TestCLIToolAssetBuilderWorks(object):
def test_CLITool_AssetBuilder_Works(self, 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, timeout=10)
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,32 @@
"""
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.
CLI tool - AssetBundlerBatch
Launch AssetBundlerBatch and Verify the help message
"""
import os
import pytest
import subprocess
@pytest.mark.SUITE_smoke
class TestCLIToolAssetBundlerBatchWorks(object):
def test_CLITool_AssetBundlerBatch_Works(self, build_directory):
file_path = os.path.join(build_directory, "AssetBundlerBatch")
help_message = "Specifies the Seed List file to operate on by path"
# Launch AssetBundlerBatch
output = subprocess.run([file_path, "--help"], capture_output=True, timeout=10)
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,26 @@
"""
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.
CLI tool - AssetProcessorBatch
Launch AssetProcessorBatch and Shutdown AssetProcessorBatch without any crash
"""
import pytest
@pytest.mark.parametrize("project", ["AutomatedTesting"])
@pytest.mark.SUITE_smoke
class TestsCLIToolAssetProcessorBatchWorks(object):
def test_CLITool_AssetProcessorBatch_Works(self, workspace):
"""
Test Launching AssetProcessorBatch and verifies that is shuts down without issue
"""
workspace.asset_processor.batch_process()

@ -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.
CLI tool - AzTestRunner
Launch AzTestRunner and Verify the help message
"""
import os
import pytest
import subprocess
@pytest.mark.SUITE_smoke
class TestCLIToolAzTestRunnerWorks(object):
def test_CLITool_AzTestRunner_Works(self, 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, timeout=10
)
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,32 @@
"""
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.
CLI tool - PythonBindingsExample
Launch PythonBindingsExample and Verify the help message
"""
import os
import pytest
import subprocess
@pytest.mark.SUITE_smoke
class TestCLIToolPythonBindingsExampleWorks(object):
def test_CLITool_PythonBindingsExample_Works(self, 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, timeout=10)
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,32 @@
"""
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.
CLI tool - SerializeContextTools
Launch SerializeContextTools and Verify the help message
"""
import os
import pytest
import subprocess
@pytest.mark.SUITE_smoke
class TestCLIToolSerializeContextToolsWorks(object):
def test_CLITool_SerializeContextTools_Works(self, 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, timeout=10)
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,32 @@
"""
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
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_Works(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_Works as test_module
self._run_test(request, workspace, editor, test_module)

@ -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.
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.SUITE_smoke
class TestStaticToolsGenPakShadersWorks(object):
def test_StaticTools_GenPakShaders_Works(self, 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)

@ -0,0 +1,39 @@
"""
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.
UI Apps: AssetProcessor
Open AssetProcessor, Wait until AssetProcessor is Idle
Close AssetProcessor.
"""
import pytest
from ly_test_tools.o3de.asset_processor import AssetProcessor
@pytest.mark.parametrize("project", ["AutomatedTesting"])
@pytest.mark.SUITE_smoke
class TestsUIAppsAssetProcessorCheckIdle(object):
@pytest.fixture(autouse=True)
def setup_teardown(self, request):
self.asset_processor = None
def teardown():
self.asset_processor.stop()
request.addfinalizer(teardown)
def test_UIApps_AssetProcessor_CheckIdle(self, workspace):
"""
Test Launching AssetProcessorBatch and verifies that is shuts down without issue
"""
self.asset_processor = AssetProcessor(workspace)
self.asset_processor.gui_process()
Loading…
Cancel
Save