Skip to content

Commit 2ec1e33

Browse files
committed
feat(coalesce): add Timeout for coalesce
Adapt waiting for coalesce to fail with a timeout if coalesce doesn't happen using wait_for. Signed-off-by: Damien Thenot <[email protected]>
1 parent 3045269 commit 2ec1e33

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

tests/storage/coalesce/test_coalesce.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import logging
2-
import time
32

3+
from lib.common import wait_for
44
from lib.host import Host
5+
from lib.vdi import VDI
6+
7+
def wait_for_vdi_coalesce(vdi: VDI):
8+
wait_for(lambda: not vdi.get_parent(), msg="Waiting for coalesce")
9+
logging.info("Coalesce done")
510

611
def copy_data_to_tapdev(host: Host, data_file: str, tapdev: str, offset: int, length: int):
712
"""
@@ -64,10 +69,7 @@ def test_coalesce(host, tapdev, vdi_with_vbd_on_dom0, data_file_on_host):
6469
logging.info("Removing VDI snapshot")
6570
host.xe("vdi-destroy", {"uuid": vdi_snap})
6671

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)
7173

7274
assert compare_data(host, tapdev, data_file_on_host, offset, length)
7375

@@ -83,11 +85,9 @@ def test_clone_coalesce(host, tapdev, vdi_with_vbd_on_dom0, data_file_on_host):
8385
logging.info("Copying data to tapdev")
8486
copy_data_to_tapdev(host, data_file_on_host, tapdev, offset, length)
8587

88+
logging.info("Removing VDI clone")
8689
host.xe("vdi-destroy", {"uuid": clone_uuid})
8790

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)
9292

9393
assert compare_data(host, tapdev, data_file_on_host, offset, length)

0 commit comments

Comments
 (0)