2020from localstack .testing .pytest import markers
2121from localstack .utils .strings import short_uid , to_bytes , to_str
2222from localstack .utils .sync import retry , wait_until
23+ from localstack .utils .testutil import get_lambda_log_events
2324from tests .aws .services .lambda_ .functions import lambda_integration
2425from tests .aws .services .lambda_ .test_lambda import TEST_LAMBDA_PYTHON
2526
@@ -572,18 +573,21 @@ def infrastructure(self, aws_client, infrastructure_setup):
572573 yield prov
573574
574575 @markers .aws .validated
575- @markers .snapshot .skip_snapshot_verify (paths = ["$..AWSTraceHeader" , "$..SenderId" ])
576+ @markers .snapshot .skip_snapshot_verify (
577+ paths = ["$..AWSTraceHeader" , "$..SenderId" , "$..eventSourceARN" ]
578+ )
576579 def test_invoke_lambda_eventbridge (self , infrastructure , aws_client , snapshot ):
577580 outputs = infrastructure .get_stack_outputs (self .EVENT_BRIDGE_STACK )
578581 input_fn_name = outputs .get (self .INPUT_FUNCTION_NAME )
579582 triggered_fn_name = outputs .get (self .TRIGGERED_FUNCTION_NAME )
580583 test_queue_name = outputs .get (self .TEST_QUEUE_NAME )
581584
585+ snapshot .add_transformer (snapshot .transform .sqs_api ())
582586 snapshot .add_transformer (snapshot .transform .key_value ("messageId" ))
583587 snapshot .add_transformer (snapshot .transform .key_value ("receiptHandle" ))
584588 snapshot .add_transformer (
585589 snapshot .transform .key_value ("SenderId" ), priority = 2
586- ) # TODO currently on LS sender-id == account-id -> replaces part of the eventSourceARN without the priority
590+ ) # TODO currently on LS sender-id == account-id -> replaces part of the eventSourceARN without the priority -> skips "$..eventSourceARN"
587591 snapshot .add_transformer (
588592 snapshot .transform .key_value (
589593 "AWSTraceHeader" , "trace-header" , reference_replacement = False
@@ -603,13 +607,9 @@ def test_invoke_lambda_eventbridge(self, infrastructure, aws_client, snapshot):
603607 wait_until_log_group_exists (triggered_fn_name , aws_client .logs )
604608
605609 def _filter_message_triggered ():
606- log_events = aws_client .logs .filter_log_events (
607- logGroupName = f"/aws/lambda/{ triggered_fn_name } "
608- )["events" ]
609- filtered_logs = [event for event in log_events if event ["message" ].startswith ("{" )]
610- assert len (filtered_logs ) >= 1
611- filtered_logs .sort (key = lambda e : e ["timestamp" ], reverse = True )
612- return filtered_logs [0 ]
613-
614- log = retry (_filter_message_triggered , retries = 50 if is_aws_cloud () else 10 )
615- snapshot .match ("filtered_message_event_bus_sqs" , log ["message" ])
610+ log_events = get_lambda_log_events (triggered_fn_name , logs_client = aws_client .logs )
611+ assert len (log_events ) >= 1
612+ return log_events [0 ]
613+
614+ logs = retry (_filter_message_triggered , retries = 50 if is_aws_cloud () else 10 )
615+ snapshot .match ("filtered_message_event_bus_sqs" , logs )
0 commit comments