36
36
from localstack .services .lambda_ .runtimes import (
37
37
ALL_RUNTIMES ,
38
38
DEPRECATED_RUNTIMES ,
39
- SNAP_START_SUPPORTED_RUNTIMES ,
40
39
)
41
40
from localstack .testing .aws .lambda_utils import (
42
41
_await_dynamodb_table_active ,
59
58
from localstack .utils .sync import ShortCircuitWaitException , wait_until
60
59
from localstack .utils .testutil import create_lambda_archive
61
60
from tests .aws .services .lambda_ .test_lambda import (
62
- TEST_LAMBDA_JAVA_WITH_LIB ,
63
61
TEST_LAMBDA_NODEJS ,
64
62
TEST_LAMBDA_PYTHON_ECHO ,
65
63
TEST_LAMBDA_PYTHON_ECHO_ZIP ,
@@ -6565,22 +6563,17 @@ def test_layer_policy_lifecycle(
6565
6563
6566
6564
class TestLambdaSnapStart :
6567
6565
@markers .aws .validated
6568
- @pytest .mark .parametrize ("runtime" , SNAP_START_SUPPORTED_RUNTIMES )
6569
- def test_snapstart_lifecycle (self , create_lambda_function , snapshot , aws_client , runtime ):
6566
+ @markers .lambda_runtime_update
6567
+ @markers .multiruntime (scenario = "echo" )
6568
+ def test_snapstart_lifecycle (self , multiruntime_lambda , snapshot , aws_client ):
6570
6569
"""Test the API of the SnapStart feature. The optimization behavior is not supported in LocalStack.
6571
6570
Slow (~1-2min) against AWS.
6572
6571
"""
6573
- function_name = f"fn-{ short_uid ()} "
6574
- java_jar_with_lib = load_file (TEST_LAMBDA_JAVA_WITH_LIB , mode = "rb" )
6575
- create_response = create_lambda_function (
6576
- func_name = function_name ,
6577
- zip_file = java_jar_with_lib ,
6578
- runtime = runtime ,
6579
- handler = "cloud.localstack.sample.LambdaHandlerWithLib" ,
6580
- SnapStart = {"ApplyOn" : "PublishedVersions" },
6572
+ create_function_response = multiruntime_lambda .create_function (
6573
+ MemorySize = 1024 , Timeout = 5 , SnapStart = {"ApplyOn" : "PublishedVersions" }
6581
6574
)
6582
- snapshot . match ( " create_function_response" , create_response )
6583
- aws_client . lambda_ . get_waiter ( "function_active_v2" ). wait ( FunctionName = function_name )
6575
+ function_name = create_function_response [ "FunctionName" ]
6576
+ snapshot . match ( "create_function_response" , create_function_response )
6584
6577
6585
6578
publish_response = aws_client .lambda_ .publish_version (
6586
6579
FunctionName = function_name , Description = "version1"
@@ -6599,20 +6592,15 @@ def test_snapstart_lifecycle(self, create_lambda_function, snapshot, aws_client,
6599
6592
snapshot .match ("get_function_response_version_1" , get_function_response )
6600
6593
6601
6594
@markers .aws .validated
6602
- @pytest .mark .parametrize ("runtime" , [Runtime .java21 , Runtime .java17 ])
6595
+ @markers .lambda_runtime_update
6596
+ @markers .multiruntime (scenario = "echo" )
6603
6597
def test_snapstart_update_function_configuration (
6604
- self , create_lambda_function , snapshot , aws_client , runtime
6598
+ self , multiruntime_lambda , snapshot , aws_client
6605
6599
):
6606
6600
"""Test enabling SnapStart when updating a function."""
6607
- function_name = f"fn-{ short_uid ()} "
6608
- java_jar_with_lib = load_file (TEST_LAMBDA_JAVA_WITH_LIB , mode = "rb" )
6609
- create_response = create_lambda_function (
6610
- func_name = function_name ,
6611
- zip_file = java_jar_with_lib ,
6612
- runtime = runtime ,
6613
- handler = "cloud.localstack.sample.LambdaHandlerWithLib" ,
6614
- )
6615
- snapshot .match ("create_function_response" , create_response )
6601
+ create_function_response = multiruntime_lambda .create_function (MemorySize = 1024 , Timeout = 5 )
6602
+ function_name = create_function_response ["FunctionName" ]
6603
+ snapshot .match ("create_function_response" , create_function_response )
6616
6604
aws_client .lambda_ .get_waiter ("function_active_v2" ).wait (FunctionName = function_name )
6617
6605
6618
6606
update_function_response = aws_client .lambda_ .update_function_configuration (
@@ -6625,19 +6613,6 @@ def test_snapstart_update_function_configuration(
6625
6613
def test_snapstart_exceptions (self , lambda_su_role , snapshot , aws_client ):
6626
6614
function_name = f"invalid-function-{ short_uid ()} "
6627
6615
zip_file_bytes = create_lambda_archive (load_file (TEST_LAMBDA_PYTHON_ECHO ), get_content = True )
6628
- # Test unsupported runtime
6629
- # Only supports java11 (2023-02-15): https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html
6630
- with pytest .raises (ClientError ) as e :
6631
- aws_client .lambda_ .create_function (
6632
- FunctionName = function_name ,
6633
- Handler = "index.handler" ,
6634
- Code = {"ZipFile" : zip_file_bytes },
6635
- PackageType = "Zip" ,
6636
- Role = lambda_su_role ,
6637
- Runtime = Runtime .python3_12 ,
6638
- SnapStart = {"ApplyOn" : "PublishedVersions" },
6639
- )
6640
- snapshot .match ("create_function_unsupported_snapstart_runtime" , e .value .response )
6641
6616
6642
6617
with pytest .raises (ClientError ) as e :
6643
6618
aws_client .lambda_ .create_function (
0 commit comments