test: update IP pool test to use Windows VMX and clarify test purpose
Lint / pssa (push) Successful in 11s
Lint / python (push) Successful in 23s

This commit is contained in:
2026-05-26 18:51:01 +02:00
parent 58d04d3bc1
commit 1a1560ec3d
2 changed files with 216 additions and 9 deletions
+15 -9
View File
@@ -580,13 +580,22 @@ def test_inject_guestinfo_ip_omits_empty_gateway(tmp_path: Path) -> None:
def test_job_with_ip_pool_uses_preassigned_ip(
monkeypatch: pytest.MonkeyPatch, tmp_path: Path, template_vmx: Path
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
) -> None:
"""When ip_pool is configured the job skips _wait_for_ip and uses the pool IP."""
"""When ip_pool is configured the job skips _wait_for_ip and uses the pool IP.
IP pool is Windows-only (guestinfo injection has no effect on Linux VMware
Tools), so this test uses a Windows VMX.
"""
from ci_orchestrator.config import Config, IpPoolConfig
from ci_orchestrator.ip_pool import IpSlotPool
backend = _FakeBackend(running_after=1)
# Windows VMX — pool guard requires guest_os != "linux".
win_vmx = tmp_path / "templates" / "WinBuild2025.vmx"
win_vmx.parent.mkdir(parents=True)
win_vmx.write_text('guestOS = "windows10srv-64"\n', encoding="utf-8")
backend = _FakeBackend(running_after=1, clone_guest_os="windows10srv-64")
calls = _patch_common(monkeypatch, backend)
pool_addresses = ["192.168.79.201"]
@@ -614,7 +623,7 @@ def test_job_with_ip_pool_uses_preassigned_ip(
base_artifact = tmp_path / "artifacts"
result = CliRunner().invoke(
cli, _common_args(template_vmx, clone_base=base_clone, artifact_base=base_artifact)
cli, _common_args(win_vmx, clone_base=base_clone, artifact_base=base_artifact)
)
assert result.exit_code == 0, result.output
@@ -629,11 +638,8 @@ def test_job_with_ip_pool_uses_preassigned_ip(
released = IpSlotPool(pool_addresses, "255.255.255.0", "", lease_file)._read_leases()
assert released["192.168.79.201"] is None
# Build was invoked with the pool IP.
assert calls["linux_build"][0]["ip_address"] == "192.168.79.201"
# VMX injection confirmed via log output (clone dir removed after job).
assert "pre-assigned" in result.output
# Build was invoked with the pool IP via the Windows branch.
assert calls["windows_build"][0]["ip_address"] == "192.168.79.201"
def test_destroy_clone_releases_pool_ip(tmp_path: Path) -> None: