66
77from lib .commands import SSHCommandFailed
88from lib .common import vm_image , wait_for
9+ from lib .host import Host
10+ from lib .vm import VM
911from tests .storage import vdi_is_open
1012
1113from .conftest import LINSTOR_PACKAGE
1214
15+ from typing import Tuple
16+
1317# Requirements:
1418# - two or more XCP-ng hosts >= 8.2 with additional unused disk(s) for the SR
1519# - access to XCP-ng RPM repository from the host
@@ -54,11 +58,11 @@ def test_create_and_destroy_sr(self, pool_with_linstor, provisioning_type, stora
5458 sr .destroy (verify = True )
5559
5660
57- def get_drbd_status (host , resource ):
61+ def get_drbd_status (host : Host , resource : str ):
5862 logging .debug (f"[{ host } ] Fetching DRBD status for resource `{ resource } `..." )
5963 return json .loads (host .ssh (["drbdsetup" , "status" , resource , "--json" ]))
6064
61- def get_corrupted_resources (host , resource ):
65+ def get_corrupted_resources (host : Host , resource : str ):
6266 return [
6367 (
6468 res .get ("name" , "" ),
@@ -71,7 +75,7 @@ def get_corrupted_resources(host, resource):
7175 if peer .get ("out-of-sync" , 0 ) > 0
7276 ]
7377
74- def wait_sync (host , resource ):
78+ def wait_drbd_sync (host : Host , resource : str ):
7579 logging .info (f"[{ host } ] Waiting for DRBD sync on resource `{ resource } `..." )
7680 host .ssh (["drbdadm" , "wait-sync" , resource ])
7781
@@ -113,7 +117,9 @@ def test_snapshot(self, vm_on_linstor_sr):
113117 vm .shutdown (verify = True )
114118
115119 @pytest .mark .small_vm
116- def test_resynchronization (self , host_and_corrupted_vdi_on_linstor_sr ):
120+ def test_resynchronization (
121+ self , host_and_corrupted_vdi_on_linstor_sr : Tuple [VM , Host , str ]
122+ ):
117123 (vm , host , resource_name ) = host_and_corrupted_vdi_on_linstor_sr
118124 hostname = host .hostname ()
119125
@@ -136,7 +142,7 @@ def test_resynchronization(self, host_and_corrupted_vdi_on_linstor_sr):
136142 logging .info (f"`drbdadm verify` attempt { attempt } /{ max_attempts } " )
137143 logging .info (f"[{ other_host } ] Running DRBD verify for `{ resource_name } `..." )
138144 other_host .ssh (["drbdadm" , "verify" , f"{ resource_name } :{ hostname } /0" ])
139- wait_sync (other_host , resource_name )
145+ wait_drbd_sync (other_host , resource_name )
140146
141147 corrupted_resources = get_corrupted_resources (other_host , resource_name )
142148 if not corrupted_resources :
@@ -156,7 +162,7 @@ def test_resynchronization(self, host_and_corrupted_vdi_on_linstor_sr):
156162 f"{ resource_name } :{ hostname } /0" ,
157163 "--reset-bitmap=no"
158164 ])
159- wait_sync (other_host , resource_name )
165+ wait_drbd_sync (other_host , resource_name )
160166 if get_corrupted_resources (other_host , resource_name ):
161167 pytest .fail ("Corrupted resource did not get fixed" )
162168
0 commit comments