diff --git a/samcli/lib/sync/infra_sync_executor.py b/samcli/lib/sync/infra_sync_executor.py index 15e166c2dd2..4b73e94c08a 100644 --- a/samcli/lib/sync/infra_sync_executor.py +++ b/samcli/lib/sync/infra_sync_executor.py @@ -72,7 +72,7 @@ class InfraSyncResult: _infra_sync_executed: bool _code_sync_resources: Set[ResourceIdentifier] - def __init__(self, executed: bool, code_sync_resources: Set[ResourceIdentifier] = set()) -> None: + def __init__(self, executed: bool, code_sync_resources: Set[ResourceIdentifier] = None) -> None: """ Constructor @@ -83,6 +83,8 @@ def __init__(self, executed: bool, code_sync_resources: Set[ResourceIdentifier] code_sync_resources: Set[ResourceIdentifier] Resources that needs a code sync """ + if code_sync_resources is None: + code_sync_resources = set() self._infra_sync_executed = executed self._code_sync_resources = code_sync_resources diff --git a/samcli/local/lambdafn/remote_files.py b/samcli/local/lambdafn/remote_files.py index 52b5e9c7cb6..ae6d2a8858d 100644 --- a/samcli/local/lambdafn/remote_files.py +++ b/samcli/local/lambdafn/remote_files.py @@ -31,7 +31,7 @@ def unzip_from_uri(uri, layer_zip_path, unzip_output_dir, progressbar_label, mou Label to use in the Progressbar """ try: - get_request = requests.get(uri, stream=True, verify=os.environ.get("AWS_CA_BUNDLE") or True) + get_request = requests.get(uri, stream=True, verify=os.environ.get("AWS_CA_BUNDLE") or True, timeout=10.0) with open(layer_zip_path, "wb") as local_layer_file: file_length = int(get_request.headers["Content-length"]) diff --git a/tests/integration/durable_integ_base.py b/tests/integration/durable_integ_base.py index 99f6abe2f9a..1cbbe2bed03 100644 --- a/tests/integration/durable_integ_base.py +++ b/tests/integration/durable_integ_base.py @@ -143,11 +143,13 @@ def log_output(): def assert_invoke_output( self, stdout: str, - input_data: Dict[str, Any] = {}, + input_data: Dict[str, Any] = None, execution_name: Optional[str] = None, expected_status: str = "SUCCEEDED", ) -> str: """Assert invoke output contains expected fields and return execution ARN.""" + if input_data is None: + input_data = {} stdout_str = stdout.strip() self.assertIn("Execution Summary:", stdout_str, f"Expected execution summary in output: {stdout_str}") diff --git a/tests/integration/local/start_api/test_start_api.py b/tests/integration/local/start_api/test_start_api.py index 37c090d73ae..ab8be7b46c9 100644 --- a/tests/integration/local/start_api/test_start_api.py +++ b/tests/integration/local/start_api/test_start_api.py @@ -1626,7 +1626,7 @@ def test_cors_swagger_options(self, origin): """ This tests that the Cors headers are added to OPTIONS responses """ - response = requests.options(self.url + "/echobase64eventbody", **_create_request_params(origin)) + response = requests.options(self.url + "/echobase64eventbody", **_create_request_params(origin), timeout=10.0) self.assert_cors(response) @parameterized.expand(["https://abc", None]) @@ -1636,7 +1636,7 @@ def test_cors_swagger_get(self, origin): """ This tests that the Cors headers are added to _other_ method responses """ - response = requests.get(self.url + "/echobase64eventbody", **_create_request_params(origin)) + response = requests.get(self.url + "/echobase64eventbody", **_create_request_params(origin), timeout=10.0) self.assert_cors(response) @@ -1762,7 +1762,7 @@ def test_cors_global(self, origin): """ This tests that the Cors headers are added to OPTIONS response when the global property is set """ - response = requests.options(self.url + "/echobase64eventbody", **_create_request_params(origin)) + response = requests.options(self.url + "/echobase64eventbody", **_create_request_params(origin), timeout=10.0) self.assertEqual(response.status_code, 200) self.assertEqual(response.headers.get("Access-Control-Allow-Origin"), "*") diff --git a/tests/integration/logs/test_logs_command.py b/tests/integration/logs/test_logs_command.py index a56b884b8ee..88d59de12b4 100644 --- a/tests/integration/logs/test_logs_command.py +++ b/tests/integration/logs/test_logs_command.py @@ -121,7 +121,7 @@ def _test_apigw_logs(self, apigw_name, path): apigw_url = f"{self._get_output_value(apigw_name_from_output)}{path}" # make couple of requests to warm-up APIGW to write its logs to CW for i in range(APIGW_REQUESTS_TO_WARM_UP): - apigw_result = requests.get(apigw_url) + apigw_result = requests.get(apigw_url, timeout=10.0) LOG.info("APIGW result %s", apigw_result) cmd_list = self.get_logs_command_list(self.stack_name, name=apigw_name) self._check_logs(cmd_list, [f"HTTP Method: GET, Resource Path: /{path}"]) @@ -138,7 +138,7 @@ def _test_end_to_end_apigw(self, apigw_name, path): # apigw name in output section doesn't have forward slashes apigw_name_from_output = apigw_name.replace("/", "") apigw_url = f"{self._get_output_value(apigw_name_from_output)}{path}" - apigw_result = requests.get(apigw_url) + apigw_result = requests.get(apigw_url, timeout=10.0) LOG.info("APIGW result %s", apigw_result) cmd_list = self.get_logs_command_list(self.stack_name) self._check_logs( @@ -154,7 +154,7 @@ def _test_end_to_end_sfn(self, apigw_name, path): # apigw name in output section doesn't have forward slashes apigw_name_from_output = apigw_name.replace("/", "") apigw_url = f"{self._get_output_value(apigw_name_from_output)}{path}" - apigw_result = requests.get(apigw_url) + apigw_result = requests.get(apigw_url, timeout=10.0) LOG.info("APIGW result %s", apigw_result) cmd_list = self.get_logs_command_list(self.stack_name) self._check_logs( diff --git a/tests/integration/sync/sync_integ_base.py b/tests/integration/sync/sync_integ_base.py index 95a3932da01..ce5fd9e7ff9 100644 --- a/tests/integration/sync/sync_integ_base.py +++ b/tests/integration/sync/sync_integ_base.py @@ -204,7 +204,7 @@ def _extract_contents_from_layer_zip(dep_dir, zipped_layer): def get_layer_contents(self, arn, dep_dir): layer = self.lambda_client.get_layer_version_by_arn(Arn=arn) layer_location = layer.get("Content", {}).get("Location", "") - zipped_layer = requests.get(layer_location) + zipped_layer = requests.get(layer_location, timeout=10.0) return SyncIntegBase._extract_contents_from_layer_zip(dep_dir, zipped_layer) def get_dependency_layer_contents_from_arn(self, stack_resources, dep_dir, version): diff --git a/tests/integration/testdata/buildcmd/asset.b998895901bf33127f2c9dce715854f8b35aa73fb7eb5245ba9721580bbe5837/requirements.txt b/tests/integration/testdata/buildcmd/asset.b998895901bf33127f2c9dce715854f8b35aa73fb7eb5245ba9721580bbe5837/requirements.txt index fd60a205345..569c40587ac 100644 --- a/tests/integration/testdata/buildcmd/asset.b998895901bf33127f2c9dce715854f8b35aa73fb7eb5245ba9721580bbe5837/requirements.txt +++ b/tests/integration/testdata/buildcmd/asset.b998895901bf33127f2c9dce715854f8b35aa73fb7eb5245ba9721580bbe5837/requirements.txt @@ -1,3 +1,3 @@ numpy<1.20.3; python_version < '3.10' numpy==1.26.4; python_version >= '3.10' -cryptography==3.3.2 \ No newline at end of file +cryptography==46.0.6 \ No newline at end of file diff --git a/tests/integration/testdata/sync/nested/after/root_function/root_function.py b/tests/integration/testdata/sync/nested/after/root_function/root_function.py index c10970f025d..3c9ac73b959 100644 --- a/tests/integration/testdata/sync/nested/after/root_function/root_function.py +++ b/tests/integration/testdata/sync/nested/after/root_function/root_function.py @@ -3,11 +3,12 @@ import requests + def lambda_handler(event, context): """Sample pure Lambda function that returns a message and a location""" try: - ip = requests.get("http://checkip.amazonaws.com/") + ip = requests.get("http://checkip.amazonaws.com/", timeout=10.0) except requests.RequestException as e: # Send some context about this error to Lambda Logs print(e) @@ -16,8 +17,5 @@ def lambda_handler(event, context): return { "statusCode": 200, - "body": json.dumps({ - "message": f"{layer_method()+6}", - "location": ip.text.replace("\n", "") - }), - } \ No newline at end of file + "body": json.dumps({"message": f"{layer_method()+6}", "location": ip.text.replace("\n", "")}), + } diff --git a/tests/integration/testdata/sync/nested/before/root_function/root_function.py b/tests/integration/testdata/sync/nested/before/root_function/root_function.py index c10970f025d..3c9ac73b959 100644 --- a/tests/integration/testdata/sync/nested/before/root_function/root_function.py +++ b/tests/integration/testdata/sync/nested/before/root_function/root_function.py @@ -3,11 +3,12 @@ import requests + def lambda_handler(event, context): """Sample pure Lambda function that returns a message and a location""" try: - ip = requests.get("http://checkip.amazonaws.com/") + ip = requests.get("http://checkip.amazonaws.com/", timeout=10.0) except requests.RequestException as e: # Send some context about this error to Lambda Logs print(e) @@ -16,8 +17,5 @@ def lambda_handler(event, context): return { "statusCode": 200, - "body": json.dumps({ - "message": f"{layer_method()+6}", - "location": ip.text.replace("\n", "") - }), - } \ No newline at end of file + "body": json.dumps({"message": f"{layer_method()+6}", "location": ip.text.replace("\n", "")}), + } diff --git a/tests/integration/testdata/sync/nested_intrinsics/before/child_stack/child_function/function/function.py b/tests/integration/testdata/sync/nested_intrinsics/before/child_stack/child_function/function/function.py index ef371620f03..b956930ac61 100644 --- a/tests/integration/testdata/sync/nested_intrinsics/before/child_stack/child_function/function/function.py +++ b/tests/integration/testdata/sync/nested_intrinsics/before/child_stack/child_function/function/function.py @@ -4,11 +4,12 @@ # import numpy as np import requests + def lambda_handler(event, context): """Sample pure Lambda function that returns a message and a location""" try: - ip = requests.get("http://checkip.amazonaws.com/") + ip = requests.get("http://checkip.amazonaws.com/", timeout=10.0) except requests.RequestException as e: # Send some context about this error to Lambda Logs print(e) @@ -17,9 +18,11 @@ def lambda_handler(event, context): return { "statusCode": 200, - "body": json.dumps({ - "message": f"{layer_method()+1}", - "location": ip.text.replace("\n", "") - # "extra_message": np.array([1, 2, 3, 4, 5, 6]).tolist() # checking external library call will succeed - }), - } \ No newline at end of file + "body": json.dumps( + { + "message": f"{layer_method()+1}", + "location": ip.text.replace("\n", ""), + # "extra_message": np.array([1, 2, 3, 4, 5, 6]).tolist() # checking external library call will succeed + } + ), + } diff --git a/tests/integration/testdata/sync/nested_intrinsics/before/child_stack/child_function/function/requirements.txt b/tests/integration/testdata/sync/nested_intrinsics/before/child_stack/child_function/function/requirements.txt index 5b6dce93d53..6e692170a02 100644 --- a/tests/integration/testdata/sync/nested_intrinsics/before/child_stack/child_function/function/requirements.txt +++ b/tests/integration/testdata/sync/nested_intrinsics/before/child_stack/child_function/function/requirements.txt @@ -1,2 +1,2 @@ numpy<=2.2.6 -requests \ No newline at end of file +requests==2.33.0 \ No newline at end of file diff --git a/tests/regression/deploy/regression_deploy_base.py b/tests/regression/deploy/regression_deploy_base.py index 2154ad69100..86c7f694ec4 100644 --- a/tests/regression/deploy/regression_deploy_base.py +++ b/tests/regression/deploy/regression_deploy_base.py @@ -85,7 +85,9 @@ def get_deploy_command_list( return command_list - def deploy_regression_check(self, args, sam_return_code=0, aws_return_code=0, commands=[]): + def deploy_regression_check(self, args, sam_return_code=0, aws_return_code=0, commands=None): + if commands is None: + commands = [] sam_stack_name = args.get("sam_stack_name", None) aws_stack_name = args.get("aws_stack_name", None) if sam_stack_name: diff --git a/tests/smoke/download_sar_templates.py b/tests/smoke/download_sar_templates.py index 17fdf956c79..01e676db767 100644 --- a/tests/smoke/download_sar_templates.py +++ b/tests/smoke/download_sar_templates.py @@ -24,6 +24,7 @@ def download(count=100): "pageNumber": current_page, "includeAppsWithCapabilities": "CAPABILITY_IAM,CAPABILITY_NAMED_IAM,CAPABILITY_RESOURCE_POLICY,CAPABILITY_AUTO_EXPAND", }, + timeout=10.0, ) response.raise_for_status() @@ -53,7 +54,7 @@ def _download_templates(app_id, template_file_path): template_url = response["Version"]["TemplateUrl"] with open(template_file_path, "wb") as fp: - r = requests.get(template_url, stream=True) + r = requests.get(template_url, stream=True, timeout=10.0) for chunk in r.iter_content(chunk_size=128): fp.write(chunk)