From 6e776bc8c10f6ace134a7038871c83d4ac7723f9 Mon Sep 17 00:00:00 2001 From: raf Date: Tue, 21 May 2024 15:01:16 +0200 Subject: [PATCH] fix: update_service reflects correct counts --- moto/ecs/models.py | 3 +++ tests/test_ecs/test_ecs_boto3.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/moto/ecs/models.py b/moto/ecs/models.py index f2518953161..18be8e7bcac 100644 --- a/moto/ecs/models.py +++ b/moto/ecs/models.py @@ -1693,6 +1693,9 @@ def update_service(self, service_properties: Dict[str, Any]) -> Service: for prop_name, prop_val in service_properties.items(): if prop_val is not None: current_service.__setattr__(prop_name, prop_val) + if prop_name == "desired_count": + current_service.__setattr__("running_count", prop_val) + current_service.__setattr__("pending_count", 0) if task_definition_str: self.describe_task_definition(task_definition_str) current_service.task_definition = task_definition_str diff --git a/tests/test_ecs/test_ecs_boto3.py b/tests/test_ecs/test_ecs_boto3.py index dd9295645d9..eb3ea0e13bf 100644 --- a/tests/test_ecs/test_ecs_boto3.py +++ b/tests/test_ecs/test_ecs_boto3.py @@ -1233,6 +1233,8 @@ def test_update_service(): desiredCount=0, ) assert response["service"]["desiredCount"] == 0 + assert response["service"]["runningCount"] == 0 + assert response["service"]["pendingCount"] == 0 assert response["service"]["schedulingStrategy"] == "REPLICA" # Verify we can pass the ARNs of the cluster and service @@ -1243,6 +1245,8 @@ def test_update_service(): desiredCount=1, ) assert response["service"]["desiredCount"] == 1 + assert response["service"]["runningCount"] == 1 + assert response["service"]["pendingCount"] == 0 @mock_aws