@@ -73,7 +73,10 @@ def test_should_not_export_again_if_not_retryable(self, mock_request):
73
73
74
74
self .assertEqual (result , LogExportResult .FAILURE )
75
75
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
+ )
77
80
@patch ("requests.Session.post" , return_value = retryable_response_no_header )
78
81
def test_should_export_again_with_backoff_if_retryable_and_no_retry_after_header (self , mock_request , mock_wait ):
79
82
"""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
95
98
self .assertEqual (mock_request .call_count , _MAX_RETRYS )
96
99
self .assertEqual (result , LogExportResult .FAILURE )
97
100
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
+ )
99
105
@patch (
100
106
"requests.Session.post" ,
101
107
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
105
111
delay if the response status code is retryable and there is a Retry-After header."""
106
112
self .exporter ._timeout = 10000 # Large timeout to avoid early exit
107
113
result = self .exporter .export (self .logs )
114
+
108
115
delays = mock_wait .call_args_list
109
116
110
117
for delay in delays :
@@ -114,7 +121,10 @@ def test_should_export_again_with_server_delay_if_retryable_and_retry_after_head
114
121
self .assertEqual (mock_request .call_count , 4 )
115
122
self .assertEqual (result , LogExportResult .SUCCESS )
116
123
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
+ )
118
128
@patch (
119
129
"requests.Session.post" ,
120
130
side_effect = [
@@ -131,6 +141,7 @@ def test_should_export_again_with_backoff_delay_if_retryable_and_bad_retry_after
131
141
but the Retry-After header is invalid or malformed."""
132
142
self .exporter ._timeout = 10000 # Large timeout to avoid early exit
133
143
result = self .exporter .export (self .logs )
144
+
134
145
delays = mock_wait .call_args_list
135
146
136
147
for index , delay in enumerate (delays ):
@@ -152,7 +163,10 @@ def test_export_connection_error_retry(self, mock_request):
152
163
self .assertEqual (mock_request .call_count , 2 )
153
164
self .assertEqual (result , LogExportResult .SUCCESS )
154
165
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
+ )
156
170
@patch ("requests.Session.post" , return_value = retryable_response_no_header )
157
171
def test_should_stop_retrying_when_deadline_exceeded (self , mock_request , mock_wait ):
158
172
"""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
172
186
# Verify total time passed is at the timeout limit
173
187
self .assertGreaterEqual (5 , self .exporter ._timeout )
174
188
189
+ @patch (
190
+ "amazon.opentelemetry.distro.exporter.otlp.aws.logs.otlp_aws_logs_exporter.Event.wait" ,
191
+ side_effect = lambda x : True ,
192
+ )
175
193
@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 ):
177
195
"""Tests that export can be interrupted by shutdown during retry wait."""
178
196
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 ()
192
204
193
205
@staticmethod
194
206
def generate_test_log_data (count = 5 ):
0 commit comments