Expand lab seed tiers, OpenAPI PARAMS, and console DATA/Params UX.
This commit is contained in:
@@ -1,27 +1,64 @@
|
||||
"""vSphere seed profile shape tests (no database)."""
|
||||
|
||||
from app.vsphere.profiles import build_vsphere_profile, large_vsphere_profile, small_vsphere_profile
|
||||
from app.vsphere.profiles import (
|
||||
PROFILE_SIZES,
|
||||
big_vsphere_profile,
|
||||
build_vsphere_profile,
|
||||
infer_profile_hint,
|
||||
large_vsphere_profile,
|
||||
minimal_vsphere_profile,
|
||||
small_vsphere_profile,
|
||||
)
|
||||
from app.vsphere.security.authz import has_privilege, privileges_for_roles
|
||||
|
||||
|
||||
def test_small_profile_has_named_vms() -> None:
|
||||
profile = small_vsphere_profile()
|
||||
def test_profile_sizes_table() -> None:
|
||||
assert PROFILE_SIZES["minimal"].vm_count == 5
|
||||
assert PROFILE_SIZES["small"].host_count == 3
|
||||
assert PROFILE_SIZES["small"].vm_count == 50
|
||||
assert PROFILE_SIZES["large"].host_count == 10
|
||||
assert PROFILE_SIZES["large"].vm_count == 1000
|
||||
assert PROFILE_SIZES["big"].host_count == 20
|
||||
assert PROFILE_SIZES["big"].vm_count == 2000
|
||||
|
||||
|
||||
def test_minimal_profile() -> None:
|
||||
profile = minimal_vsphere_profile()
|
||||
assert profile.name == "minimal"
|
||||
assert profile.vm_count == 5
|
||||
assert profile.host_count == 3
|
||||
assert len([o for o in profile.objects if o.type == "Datastore"]) == 1
|
||||
assert len([o for o in profile.objects if o.type == "Network"]) == 1
|
||||
|
||||
|
||||
def test_small_profile_has_named_vms_and_scale() -> None:
|
||||
profile = small_vsphere_profile()
|
||||
assert profile.vm_count == 50
|
||||
assert profile.host_count == 3
|
||||
assert profile.extras_scale == 1
|
||||
names = {obj.name for obj in profile.objects if obj.type == "VirtualMachine"}
|
||||
assert {"web-01", "app-01", "db-01"} <= names
|
||||
datastores = [obj for obj in profile.objects if obj.type == "Datastore"]
|
||||
assert len(datastores) == 2
|
||||
ds_ids = {d.moid for d in datastores}
|
||||
for vm in profile.objects:
|
||||
if vm.type != "VirtualMachine":
|
||||
continue
|
||||
assert vm.props.get("datastore") in ds_ids
|
||||
|
||||
|
||||
def test_large_profile_1000_vms() -> None:
|
||||
profile = large_vsphere_profile(host_count=10, vm_count=1000)
|
||||
assert profile.vm_count == 1000
|
||||
assert profile.host_count == 10
|
||||
assert profile.extras_scale == 2
|
||||
vms = [obj for obj in profile.objects if obj.type == "VirtualMachine"]
|
||||
hosts = [obj for obj in profile.objects if obj.type == "HostSystem"]
|
||||
folders = [obj for obj in profile.objects if obj.type == "Folder"]
|
||||
assert len(vms) == 1000
|
||||
assert len(hosts) == 10
|
||||
# Named cookbooks survive at the front of large inventories.
|
||||
assert len(folders) == 10 # 8 spine + 2 scaled
|
||||
assert any(obj.name == "web-01" for obj in vms)
|
||||
# Even spread across hosts
|
||||
by_host: dict[str, int] = {}
|
||||
for vm in vms:
|
||||
host = str(vm.props.get("host"))
|
||||
@@ -31,10 +68,41 @@ def test_large_profile_1000_vms() -> None:
|
||||
assert max(by_host.values()) <= 110
|
||||
|
||||
|
||||
def test_demo_cluster_profile() -> None:
|
||||
profile = build_vsphere_profile("demo-cluster")
|
||||
assert profile.vm_count == 1000
|
||||
def test_big_profile_2000_vms() -> None:
|
||||
profile = big_vsphere_profile()
|
||||
assert profile.name == "big"
|
||||
assert profile.vm_count == 2000
|
||||
assert profile.host_count == 20
|
||||
assert profile.extras_scale == 4
|
||||
datastores = [obj for obj in profile.objects if obj.type == "Datastore"]
|
||||
networks = [
|
||||
obj
|
||||
for obj in profile.objects
|
||||
if obj.type in {"Network", "DistributedVirtualPortgroup"}
|
||||
]
|
||||
folders = [obj for obj in profile.objects if obj.type == "Folder"]
|
||||
assert len(datastores) == 8
|
||||
assert len(networks) == 8
|
||||
assert len(folders) == 14 # 8 spine + 6 scaled
|
||||
ds_ids = {d.moid for d in datastores}
|
||||
for vm in profile.objects:
|
||||
if vm.type != "VirtualMachine":
|
||||
continue
|
||||
assert vm.props.get("datastore") in ds_ids
|
||||
|
||||
|
||||
def test_demo_cluster_aliases_big() -> None:
|
||||
profile = build_vsphere_profile("demo-cluster")
|
||||
assert profile.name == "big"
|
||||
assert profile.vm_count == 2000
|
||||
assert profile.host_count == 20
|
||||
|
||||
|
||||
def test_infer_profile_hint() -> None:
|
||||
assert infer_profile_hint(hosts=3, vms=5, datastores=1) == "minimal"
|
||||
assert infer_profile_hint(hosts=3, vms=50, datastores=2) == "small"
|
||||
assert infer_profile_hint(hosts=10, vms=1000, datastores=4) == "large"
|
||||
assert infer_profile_hint(hosts=20, vms=2000, datastores=8) == "big"
|
||||
|
||||
|
||||
def test_lab_credentials_include_readonly() -> None:
|
||||
|
||||
Reference in New Issue
Block a user