fix: exclude readiness probe from throttling
Some checks failed
Mostovik Backend CI/CD / Tests and lint (push) Successful in 13m38s
Mostovik Backend CI/CD / Build linux/amd64 release images (push) Failing after 3m10s
Mostovik Backend CI/CD / Deploy dev (push) Has been skipped
Mostovik Backend CI/CD / Deploy and verify internal main (push) Has been skipped
Mostovik Backend CI/CD / Deploy customer main (push) Has been skipped
Some checks failed
Mostovik Backend CI/CD / Tests and lint (push) Successful in 13m38s
Mostovik Backend CI/CD / Build linux/amd64 release images (push) Failing after 3m10s
Mostovik Backend CI/CD / Deploy dev (push) Has been skipped
Mostovik Backend CI/CD / Deploy and verify internal main (push) Has been skipped
Mostovik Backend CI/CD / Deploy customer main (push) Has been skipped
This commit is contained in:
@@ -191,6 +191,7 @@ class ReadinessView(APIView):
|
||||
|
||||
permission_classes = [AllowAny]
|
||||
authentication_classes = []
|
||||
throttle_classes = []
|
||||
|
||||
@swagger_auto_schema(
|
||||
tags=[HEALTH_TAG],
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import sys
|
||||
import types
|
||||
from datetime import timedelta
|
||||
from unittest.mock import patch
|
||||
|
||||
from apps.core import views as core_views
|
||||
from apps.core.views import HealthCheckView
|
||||
@@ -10,6 +11,7 @@ from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from rest_framework import status
|
||||
from rest_framework.test import APIRequestFactory, APITestCase
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from tests.apps.user.factories import UserFactory
|
||||
from tests.utils.fixtures import fake
|
||||
@@ -245,6 +247,20 @@ class ReadinessViewTest(APITestCase):
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(response.data["status"], "ready")
|
||||
|
||||
def test_readiness_bypasses_global_throttling(self):
|
||||
class _RejectAllThrottle:
|
||||
def allow_request(self, request, view):
|
||||
return False
|
||||
|
||||
def wait(self):
|
||||
return None
|
||||
|
||||
with patch.object(APIView, "throttle_classes", [_RejectAllThrottle]):
|
||||
response = self.client.get(reverse("core:readiness"))
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(response.data["status"], "ready")
|
||||
|
||||
def test_readiness_returns_not_ready_on_db_error(self):
|
||||
original_connection = core_views.connection
|
||||
|
||||
|
||||
Reference in New Issue
Block a user