Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion samcli/lib/sync/infra_sync_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion samcli/local/lambdafn/remote_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/durable_integ_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/local/start_api/test_start_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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)


Expand Down Expand Up @@ -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"), "*")
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/logs/test_logs_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"])
Expand All @@ -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(
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/sync/sync_integ_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
numpy<1.20.3; python_version < '3.10'
numpy==1.26.4; python_version >= '3.10'
cryptography==3.3.2
cryptography==46.0.6
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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", "")
}),
}
"body": json.dumps({"message": f"{layer_method()+6}", "location": ip.text.replace("\n", "")}),
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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", "")
}),
}
"body": json.dumps({"message": f"{layer_method()+6}", "location": ip.text.replace("\n", "")}),
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}),
}
"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
}
),
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
numpy<=2.2.6
requests
requests==2.33.0
4 changes: 3 additions & 1 deletion tests/regression/deploy/regression_deploy_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion tests/smoke/download_sar_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)

Expand Down