1
1
import logging
2
- import time
3
2
3
+ from lib .common import wait_for_not
4
4
from lib .host import Host
5
+ from lib .vdi import VDI
6
+
7
+ def wait_for_vdi_coalesce (vdi : VDI ):
8
+ wait_for_not (lambda : vdi .get_parent (), msg = "Waiting for coalesce" )
9
+ logging .info ("Coalesce done" )
5
10
6
11
def copy_data_to_tapdev (host : Host , data_file : str , tapdev : str , offset : int , length : int ):
7
12
"""
@@ -64,10 +69,7 @@ def test_coalesce(host, tapdev, vdi_with_vbd_on_dom0, data_file_on_host):
64
69
logging .info ("Removing VDI snapshot" )
65
70
host .xe ("vdi-destroy" , {"uuid" : vdi_snap })
66
71
67
- logging .info ("Waiting for coalesce" )
68
- while vdi .get_parent () is not None :
69
- time .sleep (1 )
70
- logging .info ("Coalesce done" )
72
+ wait_for_vdi_coalesce (vdi )
71
73
72
74
assert compare_data (host , tapdev , data_file_on_host , offset , length )
73
75
@@ -83,11 +85,9 @@ def test_clone_coalesce(host, tapdev, vdi_with_vbd_on_dom0, data_file_on_host):
83
85
logging .info ("Copying data to tapdev" )
84
86
copy_data_to_tapdev (host , data_file_on_host , tapdev , offset , length )
85
87
88
+ logging .info ("Removing VDI clone" )
86
89
host .xe ("vdi-destroy" , {"uuid" : clone_uuid })
87
90
88
- logging .info ("Waiting for coalesce" )
89
- while vdi .get_parent () is not None :
90
- time .sleep (1 )
91
- logging .info ("Coalesce done" )
91
+ wait_for_vdi_coalesce (vdi )
92
92
93
93
assert compare_data (host , tapdev , data_file_on_host , offset , length )
0 commit comments