diff --git a/app/celery/scheduled_tasks.py b/app/celery/scheduled_tasks.py index ec134c697..a7fe15b75 100644 --- a/app/celery/scheduled_tasks.py +++ b/app/celery/scheduled_tasks.py @@ -324,7 +324,7 @@ def batch_insert_notifications(self): current_app.logger.exception("Notification batch insert failed") for n in batch: # Use 'created_at' as a TTL so we don't retry infinitely - if datetime.fromisoformat(n.created_at) < utc_now() - timedelta(minutes=1): + if datetime.fromisoformat(n.created_at) < utc_now() - timedelta(seconds=50): current_app.logger.warning( f"Abandoning stale data, could not write to db: {n.serialize_for_redis(n)}" ) diff --git a/app/celery/tasks.py b/app/celery/tasks.py index 4086f684a..331d95364 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -256,7 +256,7 @@ def save_sms(self, service_id, notification_id, encrypted_notification, sender_i ) ) provider_tasks.deliver_sms.apply_async( - [str(saved_notification.id)], queue=QueueNames.SEND_SMS, countdown=30 + [str(saved_notification.id)], queue=QueueNames.SEND_SMS, countdown=60 ) current_app.logger.debug( diff --git a/app/notifications/process_notifications.py b/app/notifications/process_notifications.py index 02eb1f766..6b78ce753 100644 --- a/app/notifications/process_notifications.py +++ b/app/notifications/process_notifications.py @@ -174,7 +174,7 @@ def send_notification_to_queue_detached( deliver_task = provider_tasks.deliver_email try: - deliver_task.apply_async([str(notification_id)], queue=queue, countdown=30) + deliver_task.apply_async([str(notification_id)], queue=queue, countdown=60) except Exception: dao_delete_notifications_by_id(notification_id) raise diff --git a/tests/app/celery/test_scheduled_tasks.py b/tests/app/celery/test_scheduled_tasks.py index faee04081..76395832e 100644 --- a/tests/app/celery/test_scheduled_tasks.py +++ b/tests/app/celery/test_scheduled_tasks.py @@ -311,10 +311,10 @@ def test_replay_created_notifications(notify_db_session, sample_service, mocker) replay_created_notifications() email_delivery_queue.assert_called_once_with( - [str(old_email.id)], queue="send-email-tasks", countdown=30 + [str(old_email.id)], queue="send-email-tasks", countdown=60 ) sms_delivery_queue.assert_called_once_with( - [str(old_sms.id)], queue="send-sms-tasks", countdown=30 + [str(old_sms.id)], queue="send-sms-tasks", countdown=60 ) diff --git a/tests/app/celery/test_tasks.py b/tests/app/celery/test_tasks.py index eeff49251..631b02a78 100644 --- a/tests/app/celery/test_tasks.py +++ b/tests/app/celery/test_tasks.py @@ -434,7 +434,7 @@ def test_should_send_template_to_correct_sms_task_and_persist( assert persisted_notification.personalisation == {} assert persisted_notification.notification_type == NotificationType.SMS mocked_deliver_sms.assert_called_once_with( - [str(persisted_notification.id)], queue="send-sms-tasks", countdown=30 + [str(persisted_notification.id)], queue="send-sms-tasks", countdown=60 ) @@ -470,7 +470,7 @@ def test_should_save_sms_if_restricted_service_and_valid_number( assert not persisted_notification.personalisation assert persisted_notification.notification_type == NotificationType.SMS provider_tasks.deliver_sms.apply_async.assert_called_once_with( - [str(persisted_notification.id)], queue="send-sms-tasks", countdown=30 + [str(persisted_notification.id)], queue="send-sms-tasks", countdown=60 ) @@ -598,7 +598,7 @@ def test_should_save_sms_template_to_and_persist_with_job_id(sample_job, mocker) assert persisted_notification.notification_type == NotificationType.SMS provider_tasks.deliver_sms.apply_async.assert_called_once_with( - [str(persisted_notification.id)], queue="send-sms-tasks", countdown=30 + [str(persisted_notification.id)], queue="send-sms-tasks", countdown=60 ) diff --git a/tests/app/notifications/test_process_notification.py b/tests/app/notifications/test_process_notification.py index 06314ae75..84df3ac05 100644 --- a/tests/app/notifications/test_process_notification.py +++ b/tests/app/notifications/test_process_notification.py @@ -264,7 +264,7 @@ def test_send_notification_to_queue( send_notification_to_queue(notification=notification, queue=requested_queue) mocked.assert_called_once_with( - [str(notification.id)], queue=expected_queue, countdown=30 + [str(notification.id)], queue=expected_queue, countdown=60 ) @@ -278,7 +278,7 @@ def test_send_notification_to_queue_throws_exception_deletes_notification( with pytest.raises(Boto3Error): send_notification_to_queue(sample_notification, False) mocked.assert_called_once_with( - [(str(sample_notification.id))], queue="send-sms-tasks", countdown=30 + [(str(sample_notification.id))], queue="send-sms-tasks", countdown=60 ) assert _get_notification_query_count() == 0 diff --git a/tests/app/organization/test_invite_rest.py b/tests/app/organization/test_invite_rest.py index bacab402d..67d80b8cd 100644 --- a/tests/app/organization/test_invite_rest.py +++ b/tests/app/organization/test_invite_rest.py @@ -73,7 +73,7 @@ def test_create_invited_org_user( # assert len(notification.personalisation["url"]) > len(expected_start_of_invite_url) mocked.assert_called_once_with( - [(str(notification.id))], queue="notify-internal-tasks", countdown=30 + [(str(notification.id))], queue="notify-internal-tasks", countdown=60 ) diff --git a/tests/app/service/send_notification/test_send_notification.py b/tests/app/service/send_notification/test_send_notification.py index dab4ca43f..32d4c9ab9 100644 --- a/tests/app/service/send_notification/test_send_notification.py +++ b/tests/app/service/send_notification/test_send_notification.py @@ -151,7 +151,7 @@ def test_send_notification_with_placeholders_replaced( ) mocked.assert_called_once_with( - [notification_id], queue="send-email-tasks", countdown=30 + [notification_id], queue="send-email-tasks", countdown=60 ) assert response.status_code == 201 assert response_data["body"] == "Hello Jo\nThis is an email from GOV.UK" @@ -423,7 +423,7 @@ def test_should_allow_valid_sms_notification(notify_api, sample_template, mocker notification_id = response_data["notification"]["id"] mocked.assert_called_once_with( - [notification_id], queue="send-sms-tasks", countdown=30 + [notification_id], queue="send-sms-tasks", countdown=60 ) assert response.status_code == 201 assert notification_id @@ -480,7 +480,7 @@ def test_should_allow_valid_email_notification( response_data = json.loads(response.get_data(as_text=True))["data"] notification_id = response_data["notification"]["id"] app.celery.provider_tasks.deliver_email.apply_async.assert_called_once_with( - [notification_id], queue="send-email-tasks", countdown=30 + [notification_id], queue="send-email-tasks", countdown=60 ) assert response.status_code == 201 @@ -624,7 +624,7 @@ def test_should_send_email_if_team_api_key_and_a_service_user( ) app.celery.provider_tasks.deliver_email.apply_async.assert_called_once_with( - [fake_uuid], queue="send-email-tasks", countdown=30 + [fake_uuid], queue="send-email-tasks", countdown=60 ) assert response.status_code == 201 @@ -662,7 +662,7 @@ def test_should_send_sms_to_anyone_with_test_key( ], ) app.celery.provider_tasks.deliver_sms.apply_async.assert_called_once_with( - [fake_uuid], queue="send-sms-tasks", countdown=30 + [fake_uuid], queue="send-sms-tasks", countdown=60 ) assert response.status_code == 201 @@ -701,7 +701,7 @@ def test_should_send_email_to_anyone_with_test_key( ) app.celery.provider_tasks.deliver_email.apply_async.assert_called_once_with( - [fake_uuid], queue="send-email-tasks", countdown=30 + [fake_uuid], queue="send-email-tasks", countdown=60 ) assert response.status_code == 201 @@ -739,7 +739,7 @@ def test_should_send_sms_if_team_api_key_and_a_service_user( ) app.celery.provider_tasks.deliver_sms.apply_async.assert_called_once_with( - [fake_uuid], queue="send-sms-tasks", countdown=30 + [fake_uuid], queue="send-sms-tasks", countdown=60 ) assert response.status_code == 201 @@ -796,7 +796,7 @@ def test_should_persist_notification( ], ) - mocked.assert_called_once_with([fake_uuid], queue=queue_name, countdown=30) + mocked.assert_called_once_with([fake_uuid], queue=queue_name, countdown=60) assert response.status_code == 201 notification = notifications_dao.get_notification_by_id(fake_uuid) @@ -857,7 +857,7 @@ def test_should_delete_notification_and_return_error_if_redis_fails( ) assert str(e.value) == "failed to talk to redis" - mocked.assert_called_once_with([fake_uuid], queue=queue_name, countdown=30) + mocked.assert_called_once_with([fake_uuid], queue=queue_name, countdown=60) assert not notifications_dao.get_notification_by_id(fake_uuid) assert not NotificationHistory.query.get(fake_uuid) @@ -1190,7 +1190,7 @@ def test_should_allow_store_original_number_on_sms_notification( notification_id = response_data["notification"]["id"] mocked.assert_called_once_with( - [notification_id], queue="send-sms-tasks", countdown=30 + [notification_id], queue="send-sms-tasks", countdown=60 ) assert response.status_code == 201 assert notification_id diff --git a/tests/app/service/test_rest.py b/tests/app/service/test_rest.py index 2b2472ad7..7efac478a 100644 --- a/tests/app/service/test_rest.py +++ b/tests/app/service/test_rest.py @@ -3025,7 +3025,7 @@ def test_verify_reply_to_email_address_should_send_verification_email( assert notification.template_id == verify_reply_to_address_email_template.id assert response["data"] == {"id": str(notification.id)} mocked.assert_called_once_with( - [str(notification.id)], queue="notify-internal-tasks", countdown=30 + [str(notification.id)], queue="notify-internal-tasks", countdown=60 ) assert ( notification.reply_to_text diff --git a/tests/app/service_invite/test_service_invite_rest.py b/tests/app/service_invite/test_service_invite_rest.py index c43b2e878..431bb4b8c 100644 --- a/tests/app/service_invite/test_service_invite_rest.py +++ b/tests/app/service_invite/test_service_invite_rest.py @@ -90,7 +90,7 @@ def test_create_invited_user( ) mocked.assert_called_once_with( - [(str(notification.id))], queue="notify-internal-tasks", countdown=30 + [(str(notification.id))], queue="notify-internal-tasks", countdown=60 ) diff --git a/tests/app/user/test_rest.py b/tests/app/user/test_rest.py index 860e2b10b..171e88d38 100644 --- a/tests/app/user/test_rest.py +++ b/tests/app/user/test_rest.py @@ -664,7 +664,7 @@ def test_send_already_registered_email( stmt = select(Notification) notification = db.session.execute(stmt).scalars().first() mocked.assert_called_once_with( - ([str(notification.id)]), queue="notify-internal-tasks", countdown=30 + ([str(notification.id)]), queue="notify-internal-tasks", countdown=60 ) assert ( notification.reply_to_text @@ -703,7 +703,7 @@ def test_send_user_confirm_new_email_returns_204( stmt = select(Notification) notification = db.session.execute(stmt).scalars().first() mocked.assert_called_once_with( - ([str(notification.id)]), queue="notify-internal-tasks", countdown=30 + ([str(notification.id)]), queue="notify-internal-tasks", countdown=60 ) assert ( notification.reply_to_text diff --git a/tests/app/user/test_rest_verify.py b/tests/app/user/test_rest_verify.py index 805d90a8e..64a07d422 100644 --- a/tests/app/user/test_rest_verify.py +++ b/tests/app/user/test_rest_verify.py @@ -231,7 +231,7 @@ def test_send_user_sms_code(client, sample_user, sms_code_template, mocker): assert notification.reply_to_text == notify_service.get_default_sms_sender() app.celery.provider_tasks.deliver_sms.apply_async.assert_called_once_with( - ([str(notification.id)]), queue="notify-internal-tasks", countdown=30 + ([str(notification.id)]), queue="notify-internal-tasks", countdown=60 ) @@ -267,7 +267,7 @@ def test_send_user_code_for_sms_with_optional_to_field( notification = Notification.query.first() assert notification.to == "1" app.celery.provider_tasks.deliver_sms.apply_async.assert_called_once_with( - ([str(notification.id)]), queue="notify-internal-tasks", countdown=30 + ([str(notification.id)]), queue="notify-internal-tasks", countdown=60 ) @@ -349,7 +349,7 @@ def test_send_new_user_email_verification( notification = Notification.query.first() assert _get_verify_code_count() == 0 mocked.assert_called_once_with( - ([str(notification.id)]), queue="notify-internal-tasks", countdown=30 + ([str(notification.id)]), queue="notify-internal-tasks", countdown=60 ) assert ( notification.reply_to_text @@ -495,7 +495,7 @@ def test_send_user_email_code( assert noti.to == "1" assert str(noti.template_id) == current_app.config["EMAIL_2FA_TEMPLATE_ID"] deliver_email.assert_called_once_with( - [str(noti.id)], queue="notify-internal-tasks", countdown=30 + [str(noti.id)], queue="notify-internal-tasks", countdown=60 )