Skip to content

Commit 5abca49

Browse files
committed
fix test with new moto version
1 parent 99729c7 commit 5abca49

File tree

3 files changed

+40
-43
lines changed

3 files changed

+40
-43
lines changed

services/autoscaling/tests/unit/conftest.py

-1
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,6 @@ def aws_allowed_ec2_instance_type_names() -> list[InstanceTypeType]:
776776
return [
777777
"t2.xlarge",
778778
"t2.2xlarge",
779-
"g5.4xlarge",
780779
"g4dn.2xlarge",
781780
"g4dn.8xlarge",
782781
"r5n.4xlarge",

services/autoscaling/tests/unit/test_modules_auto_scaling_computational.py

+19-20
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ def minimal_configuration(
8585
disable_dynamic_service_background_task: None,
8686
disable_buffers_pool_background_task: None,
8787
mocked_redis_server: None,
88-
) -> None:
89-
...
88+
) -> None: ...
9089

9190

9291
@pytest.fixture
@@ -582,11 +581,11 @@ async def test_cluster_scaling_up_and_down( # noqa: PLR0915
582581
available=with_drain_nodes_labelled,
583582
)
584583
# update our fake node
585-
fake_attached_node.spec.labels[
586-
_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY
587-
] = mock_docker_tag_node.call_args_list[0][1]["tags"][
588-
_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY
589-
]
584+
fake_attached_node.spec.labels[_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY] = (
585+
mock_docker_tag_node.call_args_list[0][1]["tags"][
586+
_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY
587+
]
588+
)
590589
# check the activate time is later than attach time
591590
assert arrow.get(
592591
mock_docker_tag_node.call_args_list[1][1]["tags"][
@@ -611,11 +610,11 @@ async def test_cluster_scaling_up_and_down( # noqa: PLR0915
611610
available=True,
612611
)
613612
# update our fake node
614-
fake_attached_node.spec.labels[
615-
_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY
616-
] = mock_docker_tag_node.call_args_list[1][1]["tags"][
617-
_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY
618-
]
613+
fake_attached_node.spec.labels[_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY] = (
614+
mock_docker_tag_node.call_args_list[1][1]["tags"][
615+
_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY
616+
]
617+
)
619618
mock_docker_tag_node.reset_mock()
620619
mock_docker_set_node_availability.assert_not_called()
621620
mock_rabbitmq_post_message.assert_called_once()
@@ -756,9 +755,9 @@ async def test_cluster_scaling_up_and_down( # noqa: PLR0915
756755
# we artifically set the node to drain
757756
fake_attached_node.spec.availability = Availability.drain
758757
fake_attached_node.spec.labels[_OSPARC_SERVICE_READY_LABEL_KEY] = "false"
759-
fake_attached_node.spec.labels[
760-
_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY
761-
] = datetime.datetime.now(tz=datetime.UTC).isoformat()
758+
fake_attached_node.spec.labels[_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY] = (
759+
datetime.datetime.now(tz=datetime.UTC).isoformat()
760+
)
762761

763762
# the node will be not be terminated before the timeout triggers
764763
assert app_settings.AUTOSCALING_EC2_INSTANCES
@@ -960,7 +959,7 @@ async def test_cluster_does_not_scale_up_if_defined_instance_is_not_fitting_reso
960959
cpus=5, ram=TypeAdapter(ByteSize).validate_python("36Gib")
961960
),
962961
num_tasks=10,
963-
expected_instance_type="g3.4xlarge",
962+
expected_instance_type="r5n.4xlarge", # 32 cpus, 128Gib
964963
expected_num_instances=4,
965964
),
966965
id="isolve",
@@ -1429,12 +1428,12 @@ async def test_long_pending_ec2_is_detected_as_broken_terminated_and_restarted(
14291428
[
14301429
pytest.param(
14311430
_ScaleUpParams(
1432-
imposed_instance_type="g3.4xlarge", # 1 GPU, 16 CPUs, 122GiB
1431+
imposed_instance_type="g4dn.2xlarge", # 1 GPU, 8 CPUs, 32GiB
14331432
task_resources=Resources(
1434-
cpus=16, ram=TypeAdapter(ByteSize).validate_python("30Gib")
1433+
cpus=8, ram=TypeAdapter(ByteSize).validate_python("15Gib")
14351434
),
14361435
num_tasks=12,
1437-
expected_instance_type="g3.4xlarge", # 1 GPU, 16 CPUs, 122GiB
1436+
expected_instance_type="g4dn.2xlarge", # 1 GPU, 8 CPUs, 32GiB
14381437
expected_num_instances=10,
14391438
),
14401439
_ScaleUpParams(
@@ -1446,7 +1445,7 @@ async def test_long_pending_ec2_is_detected_as_broken_terminated_and_restarted(
14461445
expected_instance_type="g4dn.8xlarge", # 32CPUs, 128GiB
14471446
expected_num_instances=7,
14481447
),
1449-
id="A batch of services requiring g3.4xlarge and a batch requiring g4dn.8xlarge",
1448+
id="A batch of services requiring g4dn.2xlarge and a batch requiring g4dn.8xlarge",
14501449
),
14511450
],
14521451
)

services/autoscaling/tests/unit/test_modules_auto_scaling_dynamic.py

+21-22
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ def minimal_configuration(
204204
disable_dynamic_service_background_task: None,
205205
disable_buffers_pool_background_task: None,
206206
mocked_redis_server: None,
207-
) -> None:
208-
...
207+
) -> None: ...
209208

210209

211210
def _assert_rabbit_autoscaling_message_sent(
@@ -626,11 +625,11 @@ async def _assert_wait_for_ec2_instances_running() -> list[InstanceTypeDef]:
626625
)
627626
# update our fake node
628627
fake_attached_node.spec.labels[_OSPARC_SERVICE_READY_LABEL_KEY] = "true"
629-
fake_attached_node.spec.labels[
630-
_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY
631-
] = mock_docker_tag_node.call_args_list[2][1]["tags"][
632-
_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY
633-
]
628+
fake_attached_node.spec.labels[_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY] = (
629+
mock_docker_tag_node.call_args_list[2][1]["tags"][
630+
_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY
631+
]
632+
)
634633
# check the activate time is later than attach time
635634
assert arrow.get(
636635
mock_docker_tag_node.call_args_list[1][1]["tags"][
@@ -661,11 +660,11 @@ async def _assert_wait_for_ec2_instances_running() -> list[InstanceTypeDef]:
661660
available=True,
662661
)
663662
# update our fake node
664-
fake_attached_node.spec.labels[
665-
_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY
666-
] = mock_docker_tag_node.call_args_list[1][1]["tags"][
667-
_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY
668-
]
663+
fake_attached_node.spec.labels[_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY] = (
664+
mock_docker_tag_node.call_args_list[1][1]["tags"][
665+
_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY
666+
]
667+
)
669668
mock_docker_tag_node.reset_mock()
670669
mock_docker_set_node_availability.assert_not_called()
671670

@@ -852,9 +851,9 @@ async def _assert_wait_for_ec2_instances_running() -> list[InstanceTypeDef]:
852851
if not with_drain_nodes_labelled:
853852
fake_attached_node.spec.availability = Availability.drain
854853
fake_attached_node.spec.labels[_OSPARC_SERVICE_READY_LABEL_KEY] = "false"
855-
fake_attached_node.spec.labels[
856-
_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY
857-
] = datetime.datetime.now(tz=datetime.UTC).isoformat()
854+
fake_attached_node.spec.labels[_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY] = (
855+
datetime.datetime.now(tz=datetime.UTC).isoformat()
856+
)
858857

859858
# the node will not be terminated before the timeout triggers
860859
assert app_settings.AUTOSCALING_EC2_INSTANCES
@@ -1150,7 +1149,7 @@ async def test_cluster_scaling_up_and_down_against_aws(
11501149
cpus=5, ram=TypeAdapter(ByteSize).validate_python("36Gib")
11511150
),
11521151
num_services=10,
1153-
expected_instance_type="g3.4xlarge", # 1 GPU, 16 CPUs, 122GiB
1152+
expected_instance_type="r5n.4xlarge", # 1 GPU, 16 CPUs, 128GiB
11541153
expected_num_instances=4,
11551154
),
11561155
id="sim4life-light",
@@ -1238,12 +1237,12 @@ async def test_cluster_scaling_up_starts_multiple_instances(
12381237
[
12391238
pytest.param(
12401239
_ScaleUpParams(
1241-
imposed_instance_type="g3.4xlarge", # 1 GPU, 16 CPUs, 122GiB
1240+
imposed_instance_type="g4dn.2xlarge", # 1 GPU, 8 CPUs, 32GiB
12421241
service_resources=Resources(
1243-
cpus=16, ram=TypeAdapter(ByteSize).validate_python("30Gib")
1242+
cpus=8, ram=TypeAdapter(ByteSize).validate_python("15Gib")
12441243
),
12451244
num_services=12,
1246-
expected_instance_type="g3.4xlarge", # 1 GPU, 16 CPUs, 122GiB
1245+
expected_instance_type="g4dn.2xlarge", # 1 GPU, 8 CPUs, 32GiB
12471246
expected_num_instances=10,
12481247
),
12491248
_ScaleUpParams(
@@ -2300,9 +2299,9 @@ async def test_warm_buffers_only_replace_hot_buffer_if_service_is_started_issue7
23002299
# simulate one of the hot buffer is not drained anymore and took the pending service
23012300
random_fake_node = random.choice(fake_hot_buffer_nodes) # noqa: S311
23022301
random_fake_node.spec.labels[_OSPARC_SERVICE_READY_LABEL_KEY] = "true"
2303-
random_fake_node.spec.labels[
2304-
_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY
2305-
] = arrow.utcnow().isoformat()
2302+
random_fake_node.spec.labels[_OSPARC_SERVICES_READY_DATETIME_LABEL_KEY] = (
2303+
arrow.utcnow().isoformat()
2304+
)
23062305
random_fake_node.spec.availability = Availability.active
23072306
# simulate the fact that the warm buffer that just started is not yet visible
23082307
mock_find_node_with_name_returns_fake_node.return_value = None

0 commit comments

Comments
 (0)