From 0dc6fcb43aab1a1df2f53afddbbbc59b720436b9 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Wed, 7 Oct 2026 08:13:00 +0200 Subject: [PATCH] test: destroy_vm on a stopped VM no longer spins for a minute and gigabytes test_destroy_vm_already_stopped left the stop task a bare MagicMock, so _wait_for_task never saw "stopped" and looped for the full 60 s timeout with time.sleep patched out. Every call landed in mock_calls: the test took 60 s and up to 6 GB, and the new CI's 3.12 job was killed for it (exit 137). The stop call now raises, as Proxmox does for a VM that is not running -- which is the case the test is named for. The suite drops from 63 s to 4 s. --- tests/test_vm_provision_mixin.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_vm_provision_mixin.py b/tests/test_vm_provision_mixin.py index 0e5a487..ed9ad13 100644 --- a/tests/test_vm_provision_mixin.py +++ b/tests/test_vm_provision_mixin.py @@ -459,7 +459,13 @@ def test_destroy_vm_success(): def test_destroy_vm_already_stopped(): - """destroy_vm succeeds even if VM already stopped.""" + """destroy_vm succeeds even if VM already stopped. + + Proxmox refuses to stop a VM that is not running, so the stop call raises. + (A bare MagicMock as the stop task never reports "stopped": _wait_for_task + then spun for the full timeout with sleep patched out, and every recorded + mock call made the test take 60 s and several GB, enough for CI to kill it.) + """ mixin = ProxmoxVMProvisionMixin() mock_node = MagicMock() @@ -468,6 +474,7 @@ def test_destroy_vm_already_stopped(): # Mock VM operations mock_vm = MagicMock() mock_node.qemu.return_value = mock_vm + mock_vm.status.stop.post.side_effect = Exception("VM 101 not running") mock_vm.config.get.return_value = {} mock_vm.delete.return_value = None