Skip to content

Commit f323578

Browse files
committed
tests/misc: Specialize test_checkpoint for Windows
start_background_process seems particularly unreliable on Windows. Use the Windows equivalents to fix issues with test_checkpoint failures. Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
1 parent 95cfb61 commit f323578

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

tests/misc/test_vm_basic_operations.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@ def test_snapshot(self, running_vm: VM) -> None:
2323
vm = running_vm
2424
vm.test_snapshot_on_running_vm()
2525

26-
# When using a windows VM the background ssh process is never terminated
26+
# When running the tests on Windows, the background ssh process is never terminated
2727
# This results in a ResourceWarning
2828
@pytest.mark.filterwarnings("ignore::ResourceWarning")
2929
def test_checkpoint(self, running_vm: VM) -> None:
3030
vm = running_vm
3131
logging.info("Start a 'sleep' process on VM through SSH")
32-
pid = vm.start_background_process('sleep 10000')
32+
if vm.is_windows:
33+
pid = vm.start_background_powershell('Start-Sleep -Seconds 10000')
34+
else:
35+
pid = vm.start_background_process('sleep 10000')
36+
logging.info(f"Background task PID: {pid}")
3337
snapshot = vm.checkpoint()
3438
filepath = '/tmp/%s' % snapshot.uuid
3539
vm.ssh_touch_file(filepath)
@@ -39,8 +43,8 @@ def test_checkpoint(self, running_vm: VM) -> None:
3943
logging.info("Check file does not exist anymore")
4044
vm.ssh(f'test ! -f {filepath}')
4145
logging.info("Check 'sleep' process is still running")
42-
assert vm.pid_exists(pid)
46+
assert vm.pid_exists(pid, winpid=True)
4347
logging.info("Kill background process")
44-
vm.ssh(f'kill {pid}')
45-
wait_for_not(lambda: vm.pid_exists(pid), "Wait for process %s not running anymore" % pid)
48+
vm.kill_pid(pid, winpid=True)
49+
wait_for_not(lambda: vm.pid_exists(pid, winpid=True), "Wait for process %s not running anymore" % pid)
4650
snapshot.destroy(verify=True)

0 commit comments

Comments
 (0)