Files
Leonid PershinandCursor 789fa26918 Pick cheapest GPU SKU and pin the VM to an existing disk AZ.
Scan ru-6 by Nova availability zones (a/b/c). First boot uses FLAVOR_SIZE_PRESET=cheap; reruns stay on the disk segment.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-22 00:06:44 +03:00

55 lines
2.0 KiB
Python

from gpu_rent.pools import AzGpuOffer, PoolGpuOffer, format_pool_scan
def test_format_pool_scan_recommends_first_hit():
from gpu_rent.inventory import FlavorInfo
offers = [
PoolGpuOffer(region="ru-7", multizone=False, gpu_labels_found=[], matched=[], gpu_types=[]),
PoolGpuOffer(
region="ru-6",
multizone=True,
gpu_labels_found=["4090-24", "4090-48"],
gpu_types=["4090", "H200"],
matched=[
FlavorInfo("1", "GL-4090", 4, 16384, False, {}, "4090-24"),
],
recommended_az="ru-6a",
segments=[
AzGpuOffer(
az="ru-6a",
gpu_labels_found=["4090-24"],
gpu_types=["RTX4090"],
matched=[FlavorInfo("1", "GL-4090", 4, 16384, False, {}, "4090-24")],
),
AzGpuOffer(az="ru-6b", gpu_labels_found=[], gpu_types=["H200"], matched=[]),
AzGpuOffer(az="ru-6c", gpu_labels_found=[], gpu_types=["H200"], matched=[]),
],
),
]
text = "\n".join(format_pool_scan(offers, ("4090-24", "4090-48")))
assert "ru-6" in text and "multizone" in text
assert "типы:" in text
assert "ru-6a" in text and "ru-6b" in text and "ru-6c" in text
assert "рекомендация:" in text and "OS_REGION_NAME=ru-6" in text
assert "GPU_RENT_AZ=ru-6a" in text
def test_format_pool_scan_pins_disk_az():
from gpu_rent.inventory import FlavorInfo
offers = [
PoolGpuOffer(
region="ru-6",
multizone=True,
gpu_labels_found=["4090-24"],
gpu_types=["RTX4090"],
matched=[FlavorInfo("1", "GL-4090", 4, 16384, False, {}, "4090-24")],
recommended_az="ru-6a",
)
]
text = "\n".join(
format_pool_scan(offers, ("4090-24",), pin_az="ru-6a", size_preset="cheap")
)
assert "диск уже в ru-6a" in text