Skip to content

Commit 9a3ef15

Browse files
[integ-tests] Refactor get_ultraserver_capacity_reservation_id to be more generic considering instance type
1. Rename the function to get_capacity_reservation_id 2. In the function, use describe_capacity_reservations instead of describe_capacity_block_status because describe_capacity_reservations includes information about instance type 3. Only retrieve reservation with the right instance type 4. Let the caller of the function determines how many instances are needed
1 parent 1c938de commit 9a3ef15

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

tests/integration-tests/tests/ultraserver/test_gb200.py

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -339,31 +339,23 @@ def assert_topology_plugin_completely_disabled(cluster: Cluster):
339339
logging.info("TopologyPlugin correctly completely disabled")
340340

341341

342-
def get_ultraserver_capacity_reservation_id(instance, region):
342+
def get_capacity_reservation_id(instance_type, region, count):
343343
ec2_client = boto3.client("ec2", region_name=region)
344-
paginator = ec2_client.get_paginator("describe_capacity_block_status")
345-
344+
paginator = ec2_client.get_paginator("describe_capacity_reservations")
346345
# List to store matching reservation IDs
347-
ultraserver_reservations_ids = []
348-
346+
reservations_ids = []
349347
# Paginate through the results
350348
for page in paginator.paginate():
351-
for block in page.get("CapacityBlockStatuses", []):
352-
for reservation in block.get("CapacityReservationStatuses", []):
353-
# Check if TotalCapacity equals TotalAvailableCapacity
354-
if (
355-
reservation.get("TotalCapacity") == reservation.get("TotalAvailableCapacity")
356-
and reservation.get("TotalCapacity") is not None
357-
):
358-
359-
ultraserver_reservations_ids.append(
360-
{
361-
"CapacityReservationId": reservation["CapacityReservationId"],
362-
"TotalCapacity": reservation["TotalCapacity"],
363-
}
364-
)
365-
366-
return ultraserver_reservations_ids
349+
for reservation in page.get("CapacityReservations", []):
350+
if instance_type == reservation.get("InstanceType") and reservation.get("AvailableInstanceCount") >= count:
351+
reservations_ids.append(
352+
{
353+
"CapacityReservationId": reservation["CapacityReservationId"],
354+
"TotalInstanceCount": reservation["TotalInstanceCount"],
355+
"AvailableInstanceCount": reservation["AvailableInstanceCount"],
356+
}
357+
)
358+
return reservations_ids
367359

368360

369361
@pytest.mark.usefixtures("serial_execution_by_instance")
@@ -409,16 +401,15 @@ def test_gb200(
409401
This is a reasonable approximation for the test because the focus of the test is on IMEX and topology configuration,
410402
which can be executed on g4dn as well.
411403
"""
412-
capacity_max_queue_size = capacity_reservation_id = None
404+
capacity_reservation_id = None
405+
max_queue_size = 2
413406
if instance == "p6e-gb200.36xlarge":
414-
ultraserver_reservations_ids = get_ultraserver_capacity_reservation_id(instance, region)
407+
ultraserver_reservations_ids = get_capacity_reservation_id(instance, region, max_queue_size)
415408
if ultraserver_reservations_ids:
416409
capacity_reservation_id = ultraserver_reservations_ids[0].get("CapacityReservationId")
417-
capacity_max_queue_size = ultraserver_reservations_ids[0].get("TotalCapacity")
418410
else:
419411
pytest.skip(f"Skipping the test No Capacity Block for {instance} was found in {region}")
420412

421-
max_queue_size = 2 if capacity_max_queue_size is None else capacity_max_queue_size
422413
min_queue_size_without_imex = 1 if instance != "p6e-gb200.36xlarge" else 0
423414
capacity_block_reservation_id = capacity_reservation_id if instance == "p6e-gb200.36xlarge" else None
424415

0 commit comments

Comments
 (0)