fix: keep readiness probes unthrottled
All checks were successful
State Corp Backend CI/CD / Quality gate (push) Successful in 9m25s
State Corp Backend CI/CD / Build linux/amd64 images once (push) Successful in 4m34s
State Corp Backend CI/CD / Release dev (push) Successful in 1m2s
State Corp Backend CI/CD / Refresh and release internal main (push) Has been skipped
State Corp Backend CI/CD / Release customer main (push) Has been skipped
All checks were successful
State Corp Backend CI/CD / Quality gate (push) Successful in 9m25s
State Corp Backend CI/CD / Build linux/amd64 images once (push) Successful in 4m34s
State Corp Backend CI/CD / Release dev (push) Successful in 1m2s
State Corp Backend CI/CD / Refresh and release internal main (push) Has been skipped
State Corp Backend CI/CD / Release customer main (push) Has been skipped
This commit is contained in:
@@ -151,6 +151,7 @@ class ReadinessView(APIView):
|
|||||||
|
|
||||||
permission_classes = [AllowAny]
|
permission_classes = [AllowAny]
|
||||||
authentication_classes = []
|
authentication_classes = []
|
||||||
|
throttle_classes = []
|
||||||
|
|
||||||
@swagger_auto_schema(
|
@swagger_auto_schema(
|
||||||
tags=[HEALTH_TAG],
|
tags=[HEALTH_TAG],
|
||||||
|
|||||||
@@ -1,8 +1,19 @@
|
|||||||
"""Tests for core views (health checks)"""
|
"""Tests for core views (health checks)"""
|
||||||
|
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from rest_framework.test import APITestCase
|
from rest_framework.test import APITestCase
|
||||||
|
from rest_framework.throttling import BaseThrottle
|
||||||
|
from rest_framework.views import APIView
|
||||||
|
|
||||||
|
|
||||||
|
class RejectAllThrottle(BaseThrottle):
|
||||||
|
"""Test throttle proving readiness ignores inherited API throttles."""
|
||||||
|
|
||||||
|
def allow_request(self, request, view):
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class HealthCheckViewTest(APITestCase):
|
class HealthCheckViewTest(APITestCase):
|
||||||
@@ -66,6 +77,16 @@ class ReadinessViewTest(APITestCase):
|
|||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEqual(response.data["status"], "ready")
|
self.assertEqual(response.data["status"], "ready")
|
||||||
|
|
||||||
|
def test_readiness_bypasses_inherited_api_throttles(self):
|
||||||
|
"""Readiness probes remain available when global throttles reject traffic."""
|
||||||
|
url = reverse("core:readiness")
|
||||||
|
|
||||||
|
with patch.object(APIView, "throttle_classes", [RejectAllThrottle]):
|
||||||
|
response = self.client.get(url)
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
self.assertEqual(response.data["status"], "ready")
|
||||||
|
|
||||||
|
|
||||||
class APIVersioningURLTest(APITestCase):
|
class APIVersioningURLTest(APITestCase):
|
||||||
"""Tests for API versioning URL structure"""
|
"""Tests for API versioning URL structure"""
|
||||||
|
|||||||
Reference in New Issue
Block a user