-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Tu Dinh <[email protected]>
- Loading branch information
Tu Dinh
committed
Jan 16, 2025
1 parent
2a131f3
commit a9c0582
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import logging | ||
from pathlib import PureWindowsPath | ||
from typing import Any | ||
import pytest | ||
from lib.common import wait_for | ||
from lib.vm import VM | ||
|
||
from . import insert_cd_safe, wait_for_vm_running_and_ssh_up_without_tools | ||
|
||
|
||
def run_xenclean(vm: VM, guest_tools_iso: dict[str, Any]): | ||
insert_cd_safe(vm, guest_tools_iso["name"]) | ||
|
||
logging.info("Run XenClean") | ||
xenclean_path = PureWindowsPath("D:\\") / guest_tools_iso["xenclean_path"] | ||
xenclean_cmd = f"Set-Location C:\\; {xenclean_path} -NoReboot -Confirm:$false; Stop-Computer -Force" | ||
vm.start_background_powershell(xenclean_cmd) | ||
|
||
wait_for(vm.is_halted, "Wait for VM halted") | ||
vm.eject_cd() | ||
|
||
vm.start() | ||
wait_for_vm_running_and_ssh_up_without_tools(vm) | ||
|
||
|
||
@pytest.mark.multi_vms | ||
@pytest.mark.usefixtures("windows_vm") | ||
class TestXenClean: | ||
def test_xenclean_without_tools(self, running_unsealed_windows_vm: VM, guest_tools_iso): | ||
vm = running_unsealed_windows_vm | ||
logging.info("XenClean with empty VM") | ||
run_xenclean(vm, guest_tools_iso) | ||
assert vm.are_windows_tools_uninstalled() | ||
|
||
def test_xenclean_with_test_tools_early(self, vm_install_test_tools_no_reboot: VM, guest_tools_iso): | ||
vm = vm_install_test_tools_no_reboot | ||
logging.info("XenClean with test tools (without reboot)") | ||
run_xenclean(vm, guest_tools_iso) | ||
assert vm.are_windows_tools_uninstalled() | ||
|
||
def test_xenclean_with_test_tools(self, vm_install_test_tools_no_reboot: VM, guest_tools_iso): | ||
vm = vm_install_test_tools_no_reboot | ||
vm.reboot() | ||
# in some cases, vm.reboot(verify=False) followed by vm.insert_cd() (as called by run_xenclean) | ||
# may cause the VM to hang at the BIOS screen; wait for VM start to avoid this issue | ||
wait_for_vm_running_and_ssh_up_without_tools(vm) | ||
logging.info("XenClean with test tools") | ||
run_xenclean(vm, guest_tools_iso) | ||
assert vm.are_windows_tools_uninstalled() | ||
|
||
def test_xenclean_with_other_tools(self, vm_install_other_drivers: VM, guest_tools_iso): | ||
vm, _ = vm_install_other_drivers | ||
logging.info(f"XenClean with other tools") | ||
run_xenclean(vm, guest_tools_iso) | ||
assert vm.are_windows_tools_uninstalled() |