@@ -39,6 +39,68 @@ def multiple_logger_instances_arn(infrastructure: dict) -> str:
3939 return infrastructure .get ("MultipleLoggerInstancesArn" , "" )
4040
4141
42+ @pytest .fixture
43+ def buffer_logs_without_flush_fn (infrastructure : dict ) -> str :
44+ return infrastructure .get ("BufferLogsWithoutFlush" , "" )
45+
46+
47+ @pytest .fixture
48+ def buffer_logs_without_flush_arn (infrastructure : dict ) -> str :
49+ return infrastructure .get ("BufferLogsWithoutFlushArn" , "" )
50+
51+
52+ @pytest .fixture
53+ def buffer_logs_with_flush_fn (infrastructure : dict ) -> str :
54+ return infrastructure .get ("BufferLogsWithFlush" , "" )
55+
56+
57+ @pytest .fixture
58+ def buffer_logs_with_flush_arn (infrastructure : dict ) -> str :
59+ return infrastructure .get ("BufferLogsWithFlushArn" , "" )
60+
61+
62+ @pytest .mark .xdist_group (name = "logger" )
63+ def test_buffer_logs_without_flush (buffer_logs_without_flush_fn , buffer_logs_without_flush_arn ):
64+ # GIVEN
65+ message = "logs should be visible with default settings"
66+ message_buffer = "not visible message"
67+ payload = json .dumps ({"message_visible" : message , "message_buffered" : message_buffer })
68+
69+ # WHEN
70+ _ , execution_time = data_fetcher .get_lambda_response (lambda_arn = buffer_logs_without_flush_arn , payload = payload )
71+ data_fetcher .get_lambda_response (lambda_arn = buffer_logs_without_flush_arn , payload = payload )
72+
73+ # THEN
74+ logs = data_fetcher .get_logs (
75+ function_name = buffer_logs_without_flush_fn ,
76+ start_time = execution_time ,
77+ minimum_log_entries = 2 ,
78+ )
79+
80+ assert len (logs ) == 2
81+
82+
83+ @pytest .mark .xdist_group (name = "logger" )
84+ def test_buffer_logs_with_flush (buffer_logs_with_flush_fn , buffer_logs_with_flush_arn ):
85+ # GIVEN
86+ message = "logs should be visible with default settings"
87+ message_buffer = "not visible message"
88+ payload = json .dumps ({"message_visible" : message , "message_buffered" : message_buffer })
89+
90+ # WHEN
91+ _ , execution_time = data_fetcher .get_lambda_response (lambda_arn = buffer_logs_with_flush_arn , payload = payload )
92+ data_fetcher .get_lambda_response (lambda_arn = buffer_logs_with_flush_arn , payload = payload )
93+
94+ # THEN
95+ logs = data_fetcher .get_logs (
96+ function_name = buffer_logs_with_flush_fn ,
97+ start_time = execution_time ,
98+ minimum_log_entries = 4 ,
99+ )
100+
101+ assert len (logs ) == 4
102+
103+
42104@pytest .mark .xdist_group (name = "logger" )
43105def test_basic_lambda_logs_visible (basic_handler_fn , basic_handler_fn_arn ):
44106 # GIVEN
0 commit comments