|
10 | 10 |
|
11 | 11 | import pytest
|
12 | 12 | import requests
|
| 13 | +from requests.exceptions import InvalidURL |
13 | 14 |
|
14 | 15 | from airbyte_cdk.models import AirbyteLogMessage, AirbyteMessage, Level, SyncMode, Type
|
15 | 16 | from airbyte_cdk.sources.streams import CheckpointMixin
|
|
20 | 21 | from airbyte_cdk.sources.streams.core import StreamData
|
21 | 22 | from airbyte_cdk.sources.streams.http import HttpStream, HttpSubStream
|
22 | 23 | from airbyte_cdk.sources.streams.http.error_handlers import ErrorHandler, HttpStatusErrorHandler
|
23 |
| -from airbyte_cdk.sources.streams.http.error_handlers.response_models import ResponseAction |
| 24 | +from airbyte_cdk.sources.streams.http.error_handlers.response_models import ( |
| 25 | + FailureType, |
| 26 | + ResponseAction, |
| 27 | +) |
24 | 28 | from airbyte_cdk.sources.streams.http.exceptions import (
|
25 | 29 | DefaultBackoffException,
|
26 | 30 | RequestBodyException,
|
@@ -331,6 +335,20 @@ def test_raise_on_http_errors(mocker, error):
|
331 | 335 | assert send_mock.call_count == stream.max_retries + 1
|
332 | 336 |
|
333 | 337 |
|
| 338 | +class StubHttpStreamWithErrorHandler(StubBasicReadHttpStream): |
| 339 | + def get_error_handler(self) -> Optional[ErrorHandler]: |
| 340 | + return HttpStatusErrorHandler(logging.getLogger()) |
| 341 | + |
| 342 | + |
| 343 | +def test_dns_resolution_error_retry(): |
| 344 | + """Test that DNS resolution errors are retried""" |
| 345 | + stream = StubHttpStreamWithErrorHandler() |
| 346 | + error_handler = stream.get_error_handler() |
| 347 | + resolution = error_handler.interpret_response(InvalidURL()) |
| 348 | + assert resolution.response_action == ResponseAction.RETRY |
| 349 | + assert resolution.failure_type == FailureType.transient_error |
| 350 | + |
| 351 | + |
334 | 352 | class PostHttpStream(StubBasicReadHttpStream):
|
335 | 353 | http_method = "POST"
|
336 | 354 |
|
|
0 commit comments