Skip to content

Commit 5af35f6

Browse files
fix: apply suggestions from review
- add missing type hints in function declarations - rename wait_sync to wait_drbd_sync - rename single letter variables Co-authored-by: Antoine Bartuccio <[email protected]> Signed-off-by: Mathieu Labourier <[email protected]>
1 parent 5b26160 commit 5af35f6

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

tests/storage/linstor/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import lib.commands as commands
1111
from lib.common import safe_split
12+
from lib.sr import SR
1213

1314
# explicit import for package-scope fixtures
1415
from pkgfixtures import pool_with_saved_yum_state
@@ -141,7 +142,7 @@ def vm_on_linstor_sr(host, linstor_sr, vm_ref):
141142
vm.destroy(verify=True)
142143

143144
@pytest.fixture(scope='function')
144-
def host_and_corrupted_vdi_on_linstor_sr(host, linstor_sr, vm_ref):
145+
def host_and_corrupted_vdi_on_linstor_sr(host: Host, linstor_sr: SR, vm_ref: str):
145146
vm: VM = host.import_vm(vm_ref, sr_uuid=linstor_sr.uuid)
146147
pool: Pool = host.pool
147148
master: Host = pool.master

tests/storage/linstor/test_linstor_sr.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66

77
from lib.commands import SSHCommandFailed
88
from lib.common import vm_image, wait_for
9+
from lib.host import Host
10+
from lib.vm import VM
911
from tests.storage import vdi_is_open
1012

1113
from .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

Comments
 (0)