33import pytest
44
55import logging
6- import time
76
8- from lib .commands import SSHCommandFailed
97from lib .common import strtobool , wait_for
108from lib .vm import VM
119from lib .windows import (
12- PowerAction ,
1310 check_vm_clipboard ,
1411 check_vm_distro ,
15- check_vm_dns ,
16- set_vm_dns ,
1712 vif_has_rss ,
18- vm_shutdown_without_tools ,
1913 wait_for_vm_running_and_ssh_up_without_tools ,
2014)
21- from lib .windows .guest_tools import (
22- ERROR_INSTALL_FAILURE ,
23- install_guest_tools ,
24- uninstall_guest_tools ,
25- )
26-
27- from typing import Any , Tuple
2815
2916# Requirements:
3017# - XCP-ng >= 8.2.
7158
7259@pytest .mark .multi_vms
7360@pytest .mark .usefixtures ("windows_vm" )
74- class TestGuestToolsWindows :
61+ class TestGuestToolsWindowsNondestructive :
7562 def test_drivers_detected (self , vm_install_test_tools_per_test_class : VM ) -> None :
7663 pass
7764
78- def test_vif_replug (self , vm_install_test_tools_per_test_class : VM ) -> None :
65+ @pytest .mark .parametrize ("force" , (False , True ))
66+ def test_vif_replug (self , vm_install_test_tools_per_test_class : VM , force : bool ) -> None :
7967 vm = vm_install_test_tools_per_test_class
8068 for _iter in range (3 ):
8169 vifs = vm .vifs ()
8270 for vif in vifs :
8371 assert strtobool (vif .param_get ("currently-attached" ))
84- vif .unplug ()
85- # HACK: Allow some time for the unplug to settle. If not, Windows guests have a tendency to explode.
86- # TODO reference: XCPNG-1395
87- assert not strtobool (vif .param_get ("currently-attached" ))
88- time .sleep (5 )
72+ vif .unplug (force = force )
8973 vif .plug ()
9074 wait_for (vm .is_ssh_up , "Wait for SSH up" )
9175
@@ -111,11 +95,11 @@ def test_reporting_after_xeniface_disable(self, vm_install_test_tools_per_test_c
11195 check_vm_distro (vm )
11296 check_vm_clipboard (vm )
11397
114- def test_reporting_after_suspend (self , vm_install_test_tools_per_test_class : VM ) -> None :
98+ def test_reporting_after_migration (self , vm_install_test_tools_per_test_class : VM ) -> None :
11599 vm = vm_install_test_tools_per_test_class
100+ residence = vm .get_residence_host ()
116101 for _iter in range (3 ):
117- vm .suspend (verify = True )
118- vm .resume ()
102+ vm .migrate (residence )
119103 wait_for_vm_running_and_ssh_up_without_tools (vm )
120104 check_vm_distro (vm )
121105 check_vm_clipboard (vm )
@@ -141,54 +125,3 @@ def test_xenvbd_ssd(self, vm_install_test_tools_per_test_class: VM) -> None:
141125 )
142126 )
143127 assert is_ssd
144-
145-
146- @pytest .mark .multi_vms
147- @pytest .mark .usefixtures ("windows_vm" )
148- class TestGuestToolsWindowsDestructive :
149- def test_uninstall_tools (self , vm_install_test_tools_no_reboot : VM ) -> None :
150- vm = vm_install_test_tools_no_reboot
151- vm_shutdown_without_tools (vm )
152- vm .start ()
153- wait_for_vm_running_and_ssh_up_without_tools (vm )
154-
155- set_vm_dns (vm )
156- logging .info ("Uninstall Windows PV drivers" )
157- uninstall_guest_tools (vm , action = PowerAction .Reboot )
158- logging .info ("Check tools uninstalled" )
159- assert vm .are_windows_tools_uninstalled ()
160- check_vm_dns (vm )
161-
162- def test_uninstall_tools_early (self , vm_install_test_tools_no_reboot : VM ) -> None :
163- vm = vm_install_test_tools_no_reboot
164- logging .info ("Uninstall Windows PV drivers before rebooting" )
165- uninstall_guest_tools (vm , action = PowerAction .Reboot )
166- assert vm .are_windows_tools_uninstalled ()
167-
168- def test_install_with_other_tools (
169- self , vm_install_other_drivers : Tuple [VM , dict [str , Any ]], guest_tools_iso : dict [str , Any ]
170- ) -> None :
171- vm , param = vm_install_other_drivers
172- if param ["upgradable" ]:
173- install_guest_tools (vm , guest_tools_iso , PowerAction .Reboot , check = False )
174- assert vm .are_windows_tools_working ()
175- else :
176- exitcode = install_guest_tools (vm , guest_tools_iso , PowerAction .Nothing , check = False )
177- assert exitcode == ERROR_INSTALL_FAILURE
178-
179- @pytest .mark .usefixtures ("uefi_vm" )
180- def test_uefi_vm_suspend_refused_without_tools (self , running_unsealed_windows_vm : VM ) -> None :
181- vm = running_unsealed_windows_vm
182- with pytest .raises (SSHCommandFailed , match = "lacks the feature" ):
183- vm .suspend ()
184- wait_for_vm_running_and_ssh_up_without_tools (vm )
185-
186- # Test of the unplug rework, where the driver must remain activated even if the device ID changes.
187- # Also serves as a "close-enough" test of vendor device toggling.
188- def test_toggle_device_id (self , running_unsealed_windows_vm : VM , guest_tools_iso : dict [str , Any ]) -> None :
189- vm = running_unsealed_windows_vm
190- assert vm .param_get ("platform" , "device_id" ) == "0002"
191- install_guest_tools (vm , guest_tools_iso , PowerAction .Shutdown , check = False )
192- vm .param_set ("platform" , "0001" , "device_id" )
193- vm .start ()
194- vm .wait_for_vm_running_and_ssh_up ()
0 commit comments