From 51d3751ab696b941b87b6812c40f905636b48e7b Mon Sep 17 00:00:00 2001 From: sanderegg <35365065+sanderegg@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:27:25 +0100 Subject: [PATCH] @pcrespov review: change names --- .../simcore_service_autoscaling/api/health.py | 28 ++++++--------- .../autoscaling/tests/unit/test_api_health.py | 36 +++++++++---------- 2 files changed, 28 insertions(+), 36 deletions(-) diff --git a/services/autoscaling/src/simcore_service_autoscaling/api/health.py b/services/autoscaling/src/simcore_service_autoscaling/api/health.py index a599abea39d9..7c616e314611 100644 --- a/services/autoscaling/src/simcore_service_autoscaling/api/health.py +++ b/services/autoscaling/src/simcore_service_autoscaling/api/health.py @@ -23,36 +23,28 @@ async def health_check(): class _ComponentStatus(BaseModel): - initialized: bool - connection_state: bool - - -class _RabbitMQStatus(_ComponentStatus): - ... - - -class _EC2Status(_ComponentStatus): - ... + is_enabled: bool + is_responsive: bool class _StatusGet(BaseModel): - rabbitmq: _RabbitMQStatus - ec2: _EC2Status + rabbitmq: _ComponentStatus + ec2: _ComponentStatus @router.get("/status", include_in_schema=True, response_model=_StatusGet) async def get_status(app: FastAPI = Depends(get_app)) -> _StatusGet: return _StatusGet( - rabbitmq=_RabbitMQStatus( - initialized=bool(app.state.rabbitmq_client), - connection_state=await get_rabbitmq_client(app).ping() + rabbitmq=_ComponentStatus( + is_enabled=bool(app.state.rabbitmq_client), + is_responsive=await get_rabbitmq_client(app).ping() if app.state.rabbitmq_client else False, ), - ec2=_EC2Status( - initialized=bool(app.state.ec2_client), - connection_state=await app.state.ec2_client.ping() + ec2=_ComponentStatus( + is_enabled=bool(app.state.ec2_client), + is_responsive=await app.state.ec2_client.ping() if app.state.ec2_client else False, ), diff --git a/services/autoscaling/tests/unit/test_api_health.py b/services/autoscaling/tests/unit/test_api_health.py index 808932a722fe..523d6b927d9c 100644 --- a/services/autoscaling/tests/unit/test_api_health.py +++ b/services/autoscaling/tests/unit/test_api_health.py @@ -41,15 +41,15 @@ async def test_status_no_rabbit( status_response = response.json() assert "rabbitmq" in status_response rabbitmq_status = status_response["rabbitmq"] - assert "initialized" in rabbitmq_status - assert rabbitmq_status["initialized"] is False - assert rabbitmq_status["connection_state"] is False + assert "is_enabled" in rabbitmq_status + assert rabbitmq_status["is_enabled"] is False + assert rabbitmq_status["is_responsive"] is False assert "ec2" in status_response ec2_status = status_response["ec2"] - assert "initialized" in ec2_status - assert ec2_status["initialized"] is True - assert ec2_status["connection_state"] is True + assert "is_enabled" in ec2_status + assert ec2_status["is_enabled"] is True + assert ec2_status["is_responsive"] is True async def test_status( @@ -65,15 +65,15 @@ async def test_status( status_response = response.json() assert "rabbitmq" in status_response rabbitmq_status = status_response["rabbitmq"] - assert "initialized" in rabbitmq_status - assert rabbitmq_status["initialized"] is True - assert rabbitmq_status["connection_state"] is True + assert "is_enabled" in rabbitmq_status + assert rabbitmq_status["is_enabled"] is True + assert rabbitmq_status["is_responsive"] is True assert "ec2" in status_response ec2_status = status_response["ec2"] - assert "initialized" in ec2_status - assert ec2_status["initialized"] is True - assert ec2_status["connection_state"] is False + assert "is_enabled" in ec2_status + assert ec2_status["is_enabled"] is True + assert ec2_status["is_responsive"] is False # restart the server mocked_aws_server.start() @@ -84,12 +84,12 @@ async def test_status( status_response = response.json() assert "rabbitmq" in status_response rabbitmq_status = status_response["rabbitmq"] - assert "initialized" in rabbitmq_status - assert rabbitmq_status["initialized"] is True - assert rabbitmq_status["connection_state"] is True + assert "is_enabled" in rabbitmq_status + assert rabbitmq_status["is_enabled"] is True + assert rabbitmq_status["is_responsive"] is True assert "ec2" in status_response ec2_status = status_response["ec2"] - assert "initialized" in ec2_status - assert ec2_status["initialized"] is True - assert ec2_status["connection_state"] is True + assert "is_enabled" in ec2_status + assert ec2_status["is_enabled"] is True + assert ec2_status["is_responsive"] is True