From 4350c07027ae7513aeeba03552337a3b4667679f Mon Sep 17 00:00:00 2001 From: "Cristian O." <84862634+Criser2013@users.noreply.github.com> Date: Wed, 11 Feb 2026 18:23:41 -0500 Subject: [PATCH 1/4] =?UTF-8?q?Se=20a=C3=B1adi=C3=B3=20healthcheck=20al=20?= =?UTF-8?q?dockerfile.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 958e9d5..ac5855b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,4 +10,6 @@ RUN pip install --upgrade pip RUN pip install --no-cache-dir --no-input -r requirements.txt USER backend-user EXPOSE 80 + +HEALTHCHECK --interval=30s --timeout=5s CMD curl -f http://localhost/healthcheck || exit 1 CMD ["fastapi", "run", "./app/main.py", "--host", "0.0.0.0", "--port", "80"] \ No newline at end of file From d1b6ee82f58ff874cc6cace06b17ec257564fbc8 Mon Sep 17 00:00:00 2001 From: "Cristian O." <84862634+Criser2013@users.noreply.github.com> Date: Wed, 11 Feb 2026 18:26:33 -0500 Subject: [PATCH 2/4] =?UTF-8?q?Se=20a=C3=B1adi=C3=B3=20un=20endpoint=20par?= =?UTF-8?q?a=20verificar=20el=20healthcheck=20de=20la=20aplicaci=C3=B3n.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routers/main_router.py | 4 ++++ tests/scripts/routers/test_main_router.py | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/routers/main_router.py b/app/routers/main_router.py index 1e11240..8f04bb5 100644 --- a/app/routers/main_router.py +++ b/app/routers/main_router.py @@ -9,6 +9,10 @@ router = APIRouter(dependencies=[Depends(verificar_idioma)]) +@router.get("/healthcheck") +async def healthcheck(): + return JSONResponse({"status": "ok"}, status_code=200, media_type="application/json") + @router.get("/credenciales") async def obtener_credenciales(idioma: str = Depends(verificar_idioma)): try: diff --git a/tests/scripts/routers/test_main_router.py b/tests/scripts/routers/test_main_router.py index 9ed4df4..889be93 100644 --- a/tests/scripts/routers/test_main_router.py +++ b/tests/scripts/routers/test_main_router.py @@ -225,4 +225,16 @@ def test_74(mocker: MockerFixture): assert RES.status_code == 500 assert RES.json() == {"error": "Error al procesar la solicitud: Error de verificación"} - FUNC.assert_called_once_with("token_valido", "es") \ No newline at end of file + FUNC.assert_called_once_with("token_valido", "es") + +def test_91(): + """ + Test para validar que el endpoint de healthcheck retorne la respuesta correcta. + """ + + CLIENTE = TestClient(app.main.app) + + RES = CLIENTE.get("/healthcheck") + + assert RES.status_code == 200 + assert RES.json() == {"status": "ok"} \ No newline at end of file From 8de3ea0ac8cf12c4e74869411b49ddacc4c51f75 Mon Sep 17 00:00:00 2001 From: "Cristian O." <84862634+Criser2013@users.noreply.github.com> Date: Fri, 13 Feb 2026 17:32:38 -0500 Subject: [PATCH 3/4] Healthcheck en el dockerfile actualizado. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ac5855b..0f6b2a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,5 +11,5 @@ RUN pip install --no-cache-dir --no-input -r requirements.txt USER backend-user EXPOSE 80 -HEALTHCHECK --interval=30s --timeout=5s CMD curl -f http://localhost/healthcheck || exit 1 +HEALTHCHECK --interval=30s --timeout=5s CMD curl -H "Origin: localhost" -o /dev/null -s -w "%{http_code}\n" localhost:5000/healthcheck || exit 1 CMD ["fastapi", "run", "./app/main.py", "--host", "0.0.0.0", "--port", "80"] \ No newline at end of file From 8ea6e4d5ae6a86ac8baf60b81abe169e48fc9d4e Mon Sep 17 00:00:00 2001 From: Cristian O <84862634+Criser2013@users.noreply.github.com> Date: Fri, 13 Feb 2026 22:47:11 +0000 Subject: [PATCH 4/4] Pruebas actualizadas. --- tests/scripts/routers/test_main_router.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/routers/test_main_router.py b/tests/scripts/routers/test_main_router.py index 889be93..e83bc95 100644 --- a/tests/scripts/routers/test_main_router.py +++ b/tests/scripts/routers/test_main_router.py @@ -234,7 +234,7 @@ def test_91(): CLIENTE = TestClient(app.main.app) - RES = CLIENTE.get("/healthcheck") + RES = CLIENTE.get("/healthcheck", headers={"Origin": "http://localhost:5178", "Host": "localhost"}) assert RES.status_code == 200 assert RES.json() == {"status": "ok"} \ No newline at end of file