@@ -73,7 +73,10 @@ def test_should_not_export_again_if_not_retryable(self, mock_request):
7373
7474 self .assertEqual (result , LogExportResult .FAILURE )
7575
76- @patch ("threading.Event.wait" , side_effect = lambda x : False )
76+ @patch (
77+ "amazon.opentelemetry.distro.exporter.otlp.aws.logs.otlp_aws_logs_exporter.Event.wait" ,
78+ side_effect = lambda x : False ,
79+ )
7780 @patch ("requests.Session.post" , return_value = retryable_response_no_header )
7881 def test_should_export_again_with_backoff_if_retryable_and_no_retry_after_header (self , mock_request , mock_wait ):
7982 """Tests that multiple export requests are made with exponential delay if the response status code is retryable.
@@ -95,7 +98,10 @@ def test_should_export_again_with_backoff_if_retryable_and_no_retry_after_header
9598 self .assertEqual (mock_request .call_count , _MAX_RETRYS )
9699 self .assertEqual (result , LogExportResult .FAILURE )
97100
98- @patch ("threading.Event.wait" , side_effect = lambda x : False )
101+ @patch (
102+ "amazon.opentelemetry.distro.exporter.otlp.aws.logs.otlp_aws_logs_exporter.Event.wait" ,
103+ side_effect = lambda x : False ,
104+ )
99105 @patch (
100106 "requests.Session.post" ,
101107 side_effect = [retryable_response_header , retryable_response_header , retryable_response_header , good_response ],
@@ -105,6 +111,7 @@ def test_should_export_again_with_server_delay_if_retryable_and_retry_after_head
105111 delay if the response status code is retryable and there is a Retry-After header."""
106112 self .exporter ._timeout = 10000 # Large timeout to avoid early exit
107113 result = self .exporter .export (self .logs )
114+
108115 delays = mock_wait .call_args_list
109116
110117 for delay in delays :
@@ -114,7 +121,10 @@ def test_should_export_again_with_server_delay_if_retryable_and_retry_after_head
114121 self .assertEqual (mock_request .call_count , 4 )
115122 self .assertEqual (result , LogExportResult .SUCCESS )
116123
117- @patch ("threading.Event.wait" , side_effect = lambda x : False )
124+ @patch (
125+ "amazon.opentelemetry.distro.exporter.otlp.aws.logs.otlp_aws_logs_exporter.Event.wait" ,
126+ side_effect = lambda x : False ,
127+ )
118128 @patch (
119129 "requests.Session.post" ,
120130 side_effect = [
@@ -131,6 +141,7 @@ def test_should_export_again_with_backoff_delay_if_retryable_and_bad_retry_after
131141 but the Retry-After header is invalid or malformed."""
132142 self .exporter ._timeout = 10000 # Large timeout to avoid early exit
133143 result = self .exporter .export (self .logs )
144+
134145 delays = mock_wait .call_args_list
135146
136147 for index , delay in enumerate (delays ):
@@ -152,7 +163,10 @@ def test_export_connection_error_retry(self, mock_request):
152163 self .assertEqual (mock_request .call_count , 2 )
153164 self .assertEqual (result , LogExportResult .SUCCESS )
154165
155- @patch ("threading.Event.wait" , side_effect = lambda x : False )
166+ @patch (
167+ "amazon.opentelemetry.distro.exporter.otlp.aws.logs.otlp_aws_logs_exporter.Event.wait" ,
168+ side_effect = lambda x : False ,
169+ )
156170 @patch ("requests.Session.post" , return_value = retryable_response_no_header )
157171 def test_should_stop_retrying_when_deadline_exceeded (self , mock_request , mock_wait ):
158172 """Tests that the exporter stops retrying when the deadline is exceeded."""
@@ -172,23 +186,21 @@ def test_should_stop_retrying_when_deadline_exceeded(self, mock_request, mock_wa
172186 # Verify total time passed is at the timeout limit
173187 self .assertGreaterEqual (5 , self .exporter ._timeout )
174188
189+ @patch (
190+ "amazon.opentelemetry.distro.exporter.otlp.aws.logs.otlp_aws_logs_exporter.Event.wait" ,
191+ side_effect = lambda x : True ,
192+ )
175193 @patch ("requests.Session.post" , return_value = retryable_response_no_header )
176- def test_export_interrupted_by_shutdown (self , mock_request ):
194+ def test_export_interrupted_by_shutdown (self , mock_request , mock_wait ):
177195 """Tests that export can be interrupted by shutdown during retry wait."""
178196 self .exporter ._timeout = 10000
179-
180- # Mock Event.wait to call shutdown on first call, then return True (interrupted)
181- # We cannot call shutdown() at the beginning since the exporter would just automatically return a FAILURE result without even attempting the export.
182- def mock_wait_with_shutdown (timeout ):
183- self .exporter .shutdown ()
184- return True
185-
186- with patch .object (self .exporter ._shutdown_event , 'wait' , side_effect = mock_wait_with_shutdown ):
187- result = self .exporter .export (self .logs )
188-
189- # Should make one request, then get interrupted during retry wait
190- self .assertEqual (mock_request .call_count , 1 )
191- self .assertEqual (result , LogExportResult .FAILURE )
197+
198+ result = self .exporter .export (self .logs )
199+
200+ # Should make one request, then get interrupted during retry wait
201+ self .assertEqual (mock_request .call_count , 1 )
202+ self .assertEqual (result , LogExportResult .FAILURE )
203+ mock_wait .assert_called_once ()
192204
193205 @staticmethod
194206 def generate_test_log_data (count = 5 ):
0 commit comments