From 0ae25fe7e7d560c07a53f0df29b328246b1a2e2f Mon Sep 17 00:00:00 2001 From: jromnoa Date: Fri, 27 Aug 2021 20:35:11 -0700 Subject: [PATCH 1/3] add extra timeout value as well as some extra time.sleep() calls in an attempt to fix the test (seems race condition related) Signed-off-by: jromnoa --- .../atom_hydra_scripts/hydra_AtomMaterialEditor_BasicTests.py | 2 ++ .../Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomMaterialEditor_BasicTests.py b/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomMaterialEditor_BasicTests.py index b3c51ca912..130482cb99 100644 --- a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomMaterialEditor_BasicTests.py +++ b/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomMaterialEditor_BasicTests.py @@ -67,6 +67,7 @@ def run(): material_editor.save_document_as_child(document_id, target_path) material_editor.wait_for_condition(lambda: os.path.exists(target_path), 2.0) print(f"New asset created: {os.path.exists(target_path)}") + time.sleep(2.0) # Verify if the newly created document is open new_document_id = material_editor.open_material(target_path) @@ -101,6 +102,7 @@ def run(): expected_color = math.Color(0.25, 0.25, 0.25, 1.0) material_editor.set_property(document_id, property_name, expected_color) material_editor.save_document(document_id) + time.sleep(2.0) # 7) Test Case: Saving as a New Material # Assign new color to the material file and save the document as copy diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py b/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py index bb7a16ad6b..646c20a84f 100644 --- a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py +++ b/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py @@ -299,7 +299,7 @@ class TestMaterialEditorBasicTests(object): generic_launcher, "hydra_AtomMaterialEditor_BasicTests.py", run_python="--runpython", - timeout=80, + timeout=EDITOR_TIMEOUT, expected_lines=expected_lines, unexpected_lines=unexpected_lines, halt_on_unexpected=True, From cce532c99e573d81be2878f5100587960eff732f Mon Sep 17 00:00:00 2001 From: jromnoa Date: Mon, 30 Aug 2021 12:40:09 -0700 Subject: [PATCH 2/3] remove EDITOR_TIMEOUT constant and manually enter each time value, sets an example for future patterns to NOT use a constant for this value Signed-off-by: jromnoa --- .../Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py b/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py index 646c20a84f..c40dc8f178 100644 --- a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py +++ b/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py @@ -16,7 +16,6 @@ import editor_python_test_tools.hydra_test_utils as hydra from atom_renderer.atom_utils.atom_constants import LIGHT_TYPES logger = logging.getLogger(__name__) -EDITOR_TIMEOUT = 120 TEST_DIRECTORY = os.path.join(os.path.dirname(__file__), "atom_hydra_scripts") @@ -175,7 +174,7 @@ class TestAtomEditorComponentsMain(object): TEST_DIRECTORY, editor, "hydra_AtomEditorComponents_AddedToEntity.py", - timeout=EDITOR_TIMEOUT, + timeout=120, expected_lines=expected_lines, unexpected_lines=unexpected_lines, halt_on_unexpected=True, @@ -236,7 +235,7 @@ class TestAtomEditorComponentsMain(object): TEST_DIRECTORY, editor, "hydra_AtomEditorComponents_LightComponent.py", - timeout=EDITOR_TIMEOUT, + timeout=120, expected_lines=expected_lines, unexpected_lines=unexpected_lines, halt_on_unexpected=True, @@ -299,7 +298,7 @@ class TestMaterialEditorBasicTests(object): generic_launcher, "hydra_AtomMaterialEditor_BasicTests.py", run_python="--runpython", - timeout=EDITOR_TIMEOUT, + timeout=120, expected_lines=expected_lines, unexpected_lines=unexpected_lines, halt_on_unexpected=True, From a5f9cc2d6101276d6629082f3c7eb1ed245bb67a Mon Sep 17 00:00:00 2001 From: jromnoa Date: Mon, 30 Aug 2021 17:56:23 -0700 Subject: [PATCH 3/3] use wait_for_condition() on newly created material cache files and wait for them to exist before continuing to prevent race condition Signed-off-by: jromnoa --- .../hydra_AtomMaterialEditor_BasicTests.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomMaterialEditor_BasicTests.py b/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomMaterialEditor_BasicTests.py index 130482cb99..9047b4c871 100644 --- a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomMaterialEditor_BasicTests.py +++ b/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomMaterialEditor_BasicTests.py @@ -33,6 +33,7 @@ MATERIAL_TYPE_PATH = os.path.join( azlmbr.paths.devroot, "Gems", "Atom", "Feature", "Common", "Assets", "Materials", "Types", "StandardPBR.materialtype", ) +CACHE_FILE_EXTENSION = ".azmaterial" def run(): @@ -109,16 +110,22 @@ def run(): expected_color_1 = math.Color(0.5, 0.5, 0.5, 1.0) material_editor.set_property(document_id, property_name, expected_color_1) target_path_1 = os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Materials", NEW_MATERIAL_1) + cache_file_name_1 = os.path.splitext(NEW_MATERIAL_1) # Example output: ('test_material_1', '.material') + cache_file_1 = f"{cache_file_name_1[0]}{CACHE_FILE_EXTENSION}" + target_path_1_cache = os.path.join(azlmbr.paths.devassets, "Cache", "pc", "materials", cache_file_1) material_editor.save_document_as_copy(document_id, target_path_1) - time.sleep(2.0) + material_editor.wait_for_condition(lambda: os.path.exists(target_path_1_cache), 4.0) # 8) Test Case: Saving as a Child Material # Assign new color to the material file save the document as child expected_color_2 = math.Color(0.75, 0.75, 0.75, 1.0) material_editor.set_property(document_id, property_name, expected_color_2) target_path_2 = os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Materials", NEW_MATERIAL_2) + cache_file_name_2 = os.path.splitext(NEW_MATERIAL_1) # Example output: ('test_material_2', '.material') + cache_file_2 = f"{cache_file_name_2[0]}{CACHE_FILE_EXTENSION}" + target_path_2_cache = os.path.join(azlmbr.paths.devassets, "Cache", "pc", "materials", cache_file_2) material_editor.save_document_as_child(document_id, target_path_2) - time.sleep(2.0) + material_editor.wait_for_condition(lambda: os.path.exists(target_path_2_cache), 4.0) # Close/Reopen documents material_editor.close_all_documents()