mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-14 13:34:10 +02:00
more specific retry condition implemented
This commit is contained in:
parent
6948d6c2d4
commit
7a935d11fc
2 changed files with 12 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
||||||
from enum import IntEnum
|
from enum import IntEnum, Enum
|
||||||
|
|
||||||
|
|
||||||
class ErrorCode(IntEnum):
|
class ErrorCode(IntEnum):
|
||||||
|
@ -52,6 +52,10 @@ class ErrorCode(IntEnum):
|
||||||
SESSION_LIMIT_EXCEEDED_SERVER_CLOSING_CONNECTION = 2502
|
SESSION_LIMIT_EXCEEDED_SERVER_CLOSING_CONNECTION = 2502
|
||||||
|
|
||||||
|
|
||||||
|
class RegistryErrorMessage(Enum):
|
||||||
|
REGISTRAR_NOT_LOGGED_IN = "Registrar is not logged in."
|
||||||
|
|
||||||
|
|
||||||
class RegistryError(Exception):
|
class RegistryError(Exception):
|
||||||
"""
|
"""
|
||||||
Overview of registry response codes from RFC 5730. See RFC 5730 for full text.
|
Overview of registry response codes from RFC 5730. See RFC 5730 for full text.
|
||||||
|
@ -72,7 +76,11 @@ class RegistryError(Exception):
|
||||||
def should_retry(self):
|
def should_retry(self):
|
||||||
# COMMAND_USE_ERROR is returning with message, Registrar is not logged in,
|
# COMMAND_USE_ERROR is returning with message, Registrar is not logged in,
|
||||||
# which can be recovered from with a retry
|
# which can be recovered from with a retry
|
||||||
return self.code == ErrorCode.COMMAND_FAILED or self.code == ErrorCode.COMMAND_USE_ERROR
|
return self.code == ErrorCode.COMMAND_FAILED or (
|
||||||
|
self.code == ErrorCode.COMMAND_USE_ERROR
|
||||||
|
and self.response
|
||||||
|
and getattr(self.response, "msg", None) == RegistryErrorMessage.REGISTRAR_NOT_LOGGED_IN.value
|
||||||
|
)
|
||||||
|
|
||||||
def is_transport_error(self):
|
def is_transport_error(self):
|
||||||
return self.code == ErrorCode.TRANSPORT_ERROR
|
return self.code == ErrorCode.TRANSPORT_ERROR
|
||||||
|
|
|
@ -280,7 +280,7 @@ class TestClient(TestCase):
|
||||||
mock_close = MagicMock()
|
mock_close = MagicMock()
|
||||||
# create success and failure result messages
|
# create success and failure result messages
|
||||||
send_command_success_result = self.fake_result(1000, "Command completed successfully")
|
send_command_success_result = self.fake_result(1000, "Command completed successfully")
|
||||||
send_command_failure_result = self.fake_result(2002, "Registrar is not logging in.")
|
send_command_failure_result = self.fake_result(2002, "Registrar is not logged in.")
|
||||||
# side_effect for send call, initial send(login) succeeds during initialization, next send(command)
|
# side_effect for send call, initial send(login) succeeds during initialization, next send(command)
|
||||||
# fails, subsequent sends (logout, login, command) all succeed
|
# fails, subsequent sends (logout, login, command) all succeed
|
||||||
send_call_count = 0
|
send_call_count = 0
|
||||||
|
@ -312,7 +312,7 @@ class TestClient(TestCase):
|
||||||
self.assertEquals(mock_send.call_count, 5)
|
self.assertEquals(mock_send.call_count, 5)
|
||||||
# Assertion proper logging; note that the
|
# Assertion proper logging; note that the
|
||||||
mock_logger.info.assert_called_once_with(
|
mock_logger.info.assert_called_once_with(
|
||||||
"InfoDomainCommand failed and will be retried Error: Registrar is not logging in.| cltrid is cl_tr_id svtrid is sv_tr_id"
|
"InfoDomainCommand failed and will be retried Error: Registrar is not logged in.| cltrid is cl_tr_id svtrid is sv_tr_id"
|
||||||
)
|
)
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue