mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-10 10:03:21 -04:00
Reduce timeout to 45 seconds following analysis by Chris H-S:
"Failure is slower than success. So the longer a notification takes to get a status, the more likely it is for that status to be a failure anyway. This increases dramatically after 45 seconds. The percentage of emails that go to delivered in less than 90 seconds is 98.92%. To get to 99% we’d need to increase the timeout to 178 seconds (3 minutes). We could still get 98.7% of notifications by dropping the timeout to 45 seconds, and improve the experience for notifications that are likely to fail by returning an error more quickly."
This commit is contained in:
@@ -481,7 +481,7 @@ def get_service_verify_reply_to_address_partials(service_id, notification_id):
|
|||||||
created_at_no_tz = notification["created_at"][:-6]
|
created_at_no_tz = notification["created_at"][:-6]
|
||||||
seconds_since_sending = (datetime.utcnow() - datetime.strptime(created_at_no_tz, '%Y-%m-%dT%H:%M:%S.%f')).seconds
|
seconds_since_sending = (datetime.utcnow() - datetime.strptime(created_at_no_tz, '%Y-%m-%dT%H:%M:%S.%f')).seconds
|
||||||
if notification["status"] in FAILURE_STATUSES or (
|
if notification["status"] in FAILURE_STATUSES or (
|
||||||
notification["status"] in SENDING_STATUSES and seconds_since_sending > 90
|
notification["status"] in SENDING_STATUSES and seconds_since_sending > 45
|
||||||
):
|
):
|
||||||
verification_status = "failure"
|
verification_status = "failure"
|
||||||
form.email_address.data = notification['to']
|
form.email_address.data = notification['to']
|
||||||
|
|||||||
@@ -2088,7 +2088,7 @@ def test_service_verify_reply_to_address(
|
|||||||
|
|
||||||
|
|
||||||
@freeze_time("2018-06-01 11:11:00.061258")
|
@freeze_time("2018-06-01 11:11:00.061258")
|
||||||
def test_add_reply_to_email_address_fails_if_notification_not_delivered_in_5_mins(mocker, client_request, fake_uuid):
|
def test_add_reply_to_email_address_fails_if_notification_not_delivered_in_45_sec(mocker, client_request, fake_uuid):
|
||||||
notification = {
|
notification = {
|
||||||
"id": fake_uuid,
|
"id": fake_uuid,
|
||||||
"status": "sending",
|
"status": "sending",
|
||||||
@@ -2096,7 +2096,7 @@ def test_add_reply_to_email_address_fails_if_notification_not_delivered_in_5_min
|
|||||||
"service_id": SERVICE_ONE_ID,
|
"service_id": SERVICE_ONE_ID,
|
||||||
"template_id": TEMPLATE_ONE_ID,
|
"template_id": TEMPLATE_ONE_ID,
|
||||||
"notification_type": "email",
|
"notification_type": "email",
|
||||||
"created_at": '2018-06-01T11:05:52.499230+00:00'
|
"created_at": '2018-06-01T11:10:12.499230+00:00'
|
||||||
}
|
}
|
||||||
mocker.patch(
|
mocker.patch(
|
||||||
'app.service_api_client.get_reply_to_email_addresses', return_value=[]
|
'app.service_api_client.get_reply_to_email_addresses', return_value=[]
|
||||||
@@ -2112,7 +2112,6 @@ def test_add_reply_to_email_address_fails_if_notification_not_delivered_in_5_min
|
|||||||
expected_banner = page.find_all('div', class_='banner-dangerous')[0]
|
expected_banner = page.find_all('div', class_='banner-dangerous')[0]
|
||||||
assert 'There’s a problem with your reply-to address' in expected_banner.text.strip()
|
assert 'There’s a problem with your reply-to address' in expected_banner.text.strip()
|
||||||
mock_add_reply_to_email_address.assert_not_called()
|
mock_add_reply_to_email_address.assert_not_called()
|
||||||
# add check that form is visible
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('fixture, data, api_default_args', [
|
@pytest.mark.parametrize('fixture, data, api_default_args', [
|
||||||
|
|||||||
Reference in New Issue
Block a user