From d378bc960f2b54eab6311f6337b32577e9cb12bc Mon Sep 17 00:00:00 2001 From: Daniel Mil <84205762+mildaniel@users.noreply.github.com> Date: Thu, 23 Nov 2023 12:23:00 -0800 Subject: [PATCH] fix(test): Hanging init tests with new structured logging input (#6331) * fix: Init tests * Fix remaining tests * Fix comments * Add a global timeout --- pytest.ini | 2 + .../init/schemas/schemas_test_data_setup.py | 22 -------- .../schemas/test_init_with_schemas_command.py | 56 +++++++++++++++---- tests/integration/init/test_init_command.py | 2 + 4 files changed, 48 insertions(+), 34 deletions(-) diff --git a/pytest.ini b/pytest.ini index 1f186fe400..c48ab402e6 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,6 @@ [pytest] +; timeout any test after 30 minutes if it's hanging +timeout = 1800 log_cli = 1 log_cli_level = INFO addopts = --maxfail=1000 -rf diff --git a/tests/integration/init/schemas/schemas_test_data_setup.py b/tests/integration/init/schemas/schemas_test_data_setup.py index 90f90c29a2..b18d200867 100644 --- a/tests/integration/init/schemas/schemas_test_data_setup.py +++ b/tests/integration/init/schemas/schemas_test_data_setup.py @@ -43,28 +43,6 @@ def setUpClass(cls): setup_partner_schema_data("partner-registry", schemas_client) setup_schema_data_for_pagination("test-pagination", schemas_client) setup_non_partner_schema_data("other-schema", schemas_client) - # WHEN the user follows interactive init prompts - # 1: AWS Quick Start Templates - # 1: Hello World Example - # N: do not use DEFAULT hello world template - # 11: Java runtime - # 2: dependency manager maven - # eb-app-maven: response to name - # Y: clone/update the source repo - # 1: hello world - - user_input = """ -1 -1 -N -5 -1 -2 -eb-app-maven - """ - with tempfile.TemporaryDirectory() as temp: - runner = CliRunner() - runner.invoke(init_cmd, ["--output-dir", temp], input=user_input) def tearDown(self) -> None: env = os.environ diff --git a/tests/integration/init/schemas/test_init_with_schemas_command.py b/tests/integration/init/schemas/test_init_with_schemas_command.py index 37a0e9ec4c..c7debf593b 100644 --- a/tests/integration/init/schemas/test_init_with_schemas_command.py +++ b/tests/integration/init/schemas/test_init_with_schemas_command.py @@ -17,6 +17,7 @@ @skipIf(SKIP_SCHEMA_TESTS, "Skip schema test") @pytest.mark.xdist_group(name="sam_init") class TestBasicInitWithEventBridgeCommand(SchemaTestDataSetup): + @pytest.mark.timeout(300) def test_init_interactive_with_event_bridge_app_aws_registry(self): # WHEN the user follows interactive init prompts # 1: AWS Quick Start Templates @@ -25,6 +26,8 @@ def test_init_interactive_with_event_bridge_app_aws_registry(self): # 2: Maven # 2: select event-bridge app from scratch # N: disable adding xray tracing + # N: disable cloudwatch insights + # N: disable structured logging # test-project: response to name # Y: Use default aws configuration # 1: select schema from cli_paginator @@ -39,6 +42,7 @@ def test_init_interactive_with_event_bridge_app_aws_registry(self): 2 N N +N eb-app-maven Y 1 @@ -57,6 +61,7 @@ def test_init_interactive_with_event_bridge_app_aws_registry(self): Path(expected_output_folder, "HelloWorldFunction", "src", "main", "java", "schema").is_dir() ) + @pytest.mark.timeout(300) def test_init_interactive_with_event_bridge_app_partner_registry(self): # setup schema data # WHEN the user follows interactive init prompts @@ -66,6 +71,8 @@ def test_init_interactive_with_event_bridge_app_partner_registry(self): # 2: Maven # 2: select event-bridge app from scratch # N: disable adding xray tracing + # N: disable cloudwatch insights + # N: disable structured logging # test-project: response to name # Y: Use default aws configuration # 3: partner registry @@ -79,6 +86,7 @@ def test_init_interactive_with_event_bridge_app_partner_registry(self): 2 N N +N eb-app-maven Y 3 @@ -108,6 +116,7 @@ def test_init_interactive_with_event_bridge_app_partner_registry(self): ).is_file() ) + @pytest.mark.timeout(300) def test_init_interactive_with_event_bridge_app_pagination(self): # WHEN the user follows interactive init prompts # 1: AWS Quick Start Templates @@ -116,6 +125,8 @@ def test_init_interactive_with_event_bridge_app_pagination(self): # 2: Maven # 2: select event-bridge app from scratch # N: disable adding xray tracing + # N: disable cloudwatch insights + # N: disable structured logging # eb-app-maven: response to name # Y: Use default aws configuration # 4: select pagination-registry as registries @@ -131,6 +142,7 @@ def test_init_interactive_with_event_bridge_app_pagination(self): 2 N N +N eb-app-maven Y 4 @@ -151,6 +163,7 @@ def test_init_interactive_with_event_bridge_app_pagination(self): Path(expected_output_folder, "HelloWorldFunction", "src", "main", "java", "schema").is_dir() ) + @pytest.mark.timeout(300) def test_init_interactive_with_event_bridge_app_customer_registry(self): # WHEN the user follows interactive init prompts # 1: AWS Quick Start Templates @@ -159,6 +172,8 @@ def test_init_interactive_with_event_bridge_app_customer_registry(self): # 2: Maven # 2: select event-bridge app from scratch # N: disable adding xray tracing + # N: disable cloudwatch insights + # N: disable structured logging # eb-app-maven: response to name # Y: Use default aws configuration # 2: select 2p-schema other-schema @@ -172,6 +187,7 @@ def test_init_interactive_with_event_bridge_app_customer_registry(self): 2 N N +N eb-app-maven Y 2 @@ -201,14 +217,17 @@ def test_init_interactive_with_event_bridge_app_customer_registry(self): ).is_file() ) + @pytest.mark.timeout(300) def test_init_interactive_with_event_bridge_app_aws_schemas_python(self): # WHEN the user follows interactive init prompts # 1: AWS Quick Start Templates # 8: Infrastructure event management - Use case - # 7: Python 3.9 + # 8: Python 3.9 # 2: select event-bridge app from scratch # N: disable adding xray tracing - # eb-app-python38: response to name + # N: disable cloudwatch insights + # N: disable structured logging + # eb-app-python39: response to name # Y: Use default aws configuration # 4: select aws.events as registries # 1: select aws schema @@ -216,11 +235,12 @@ def test_init_interactive_with_event_bridge_app_aws_schemas_python(self): user_input = """ 1 8 -7 +8 2 N N -eb-app-python38 +N +eb-app-python39 Y 1 4 @@ -231,11 +251,12 @@ def test_init_interactive_with_event_bridge_app_aws_schemas_python(self): result = runner.invoke(init_cmd, ["--output-dir", temp], input=user_input) self.assertFalse(result.exception) - expected_output_folder = Path(temp, "eb-app-python38") + expected_output_folder = Path(temp, "eb-app-python39") self.assertTrue(expected_output_folder.exists) self.assertTrue(expected_output_folder.is_dir()) self.assertTrue(Path(expected_output_folder, "hello_world_function", "schema").is_dir()) + @pytest.mark.timeout(300) def test_init_interactive_with_event_bridge_app_aws_schemas_go(self): # WHEN the user follows interactive init prompts # 1: AWS Quick Start Templates @@ -243,6 +264,8 @@ def test_init_interactive_with_event_bridge_app_aws_schemas_go(self): # 1: Go 1.x # 2: select event-bridge app from scratch # N: disable adding xray tracing + # N: disable cloudwatch insights + # N: disable structured logging # eb-app-go: response to name # Y: Use default aws configuration # 4: select aws.events as registries @@ -255,6 +278,7 @@ def test_init_interactive_with_event_bridge_app_aws_schemas_go(self): 2 N N +N eb-app-go Y 4 @@ -270,14 +294,17 @@ def test_init_interactive_with_event_bridge_app_aws_schemas_go(self): self.assertTrue(expected_output_folder.is_dir()) self.assertTrue(Path(expected_output_folder, "HelloWorld", "schema").is_dir()) + @pytest.mark.timeout(300) def test_init_interactive_with_event_bridge_app_non_default_profile_selection(self): self._init_custom_config("mynewprofile", "us-west-2") # WHEN the user follows interactive init prompts # 1: AWS Quick Start Templates # 8: Infrastructure event management - Use case - # 7: Python 3.9 + # 8: Python 3.9 # 2: select event-bridge app from scratch # N: disable adding xray tracing + # N: disable cloudwatch insights + # N: disable structured logging # eb-app-python38: response to name # N: Use default profile # 2: uses second profile from displayed one (myprofile) @@ -288,11 +315,12 @@ def test_init_interactive_with_event_bridge_app_non_default_profile_selection(se user_input = """ 1 8 -7 +8 2 N N -eb-app-python38 +N +eb-app-python39 3 N 2 @@ -305,11 +333,12 @@ def test_init_interactive_with_event_bridge_app_non_default_profile_selection(se result = runner.invoke(init_cmd, ["--output-dir", temp], input=user_input) self.assertFalse(result.exception) - expected_output_folder = Path(temp, "eb-app-python38") + expected_output_folder = Path(temp, "eb-app-python39") self.assertTrue(expected_output_folder.exists) self.assertTrue(expected_output_folder.is_dir()) self.assertTrue(Path(expected_output_folder, "hello_world_function", "schema").is_dir()) + @pytest.mark.timeout(300) def test_init_interactive_with_event_bridge_app_non_supported_schemas_region(self): self._init_custom_config("default", "cn-north-1") # WHEN the user follows interactive init prompts @@ -318,7 +347,9 @@ def test_init_interactive_with_event_bridge_app_non_supported_schemas_region(sel # 7: Python 3.9 # 2: select event-bridge app from scratch # N: disable adding xray tracing - # eb-app-python38: response to name + # N: disable cloudwatch insights + # N: disable structured logging + # eb-app-python39: response to name # Y: Use default profile # 1: select aws.events as registries # 1: select aws schema @@ -326,11 +357,12 @@ def test_init_interactive_with_event_bridge_app_non_supported_schemas_region(sel user_input = """ 1 8 -7 +8 2 N N -eb-app-python38 +N +eb-app-python39 Y 1 1 diff --git a/tests/integration/init/test_init_command.py b/tests/integration/init/test_init_command.py index d59519e448..c3ce6713a7 100644 --- a/tests/integration/init/test_init_command.py +++ b/tests/integration/init/test_init_command.py @@ -897,6 +897,7 @@ def test_location_with_no_interactive_and_name(self): @pytest.mark.xdist_group(name="sam_init") class TestInteractiveInit(TestCase): + @pytest.mark.timeout(300) def test_interactive_init(self): # 1: AWS Quick Start Templates # 1: Hello World Example @@ -930,6 +931,7 @@ def test_interactive_init(self): self.assertTrue(Path(expected_output_folder, "hello-world").is_dir()) self.assertTrue(Path(expected_output_folder, "hello-world", "app.mjs").is_file()) + @pytest.mark.timeout(300) def test_interactive_init_default_runtime(self): user_input = """ 1