Skip to content

Commit 30b9316

Browse files
committed
linstor: add fixture to get LVM disk paths
This extracts the `host_devices` function of the `lvm_disks` fixture in the LINSTOR SR tests into its own fixture. This allows getting the paths to the physical disks used in the LVM volume in other fixtures and the tests, and overriding those paths in sub-packages. Signed-off-by: Alexandre Sollier <alexandre.sollier@vates.tech>
1 parent 48bdf0e commit 30b9316

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

tests/storage/linstor/conftest.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,16 @@ class LinstorConfig:
4848
def _linstor_config() -> LinstorConfig:
4949
return LinstorConfig()
5050

51+
@pytest.fixture(scope='package')
52+
def lvm_disk_paths(
53+
unused_512B_disks: dict[Host, list[Host.BlockDeviceInfo]],
54+
) -> dict[Host, list[str]]:
55+
return {host: [disk.path for disk in disks[0:1]] for (host, disks) in unused_512B_disks.items()}
56+
5157
@pytest.fixture(scope='package')
5258
def lvm_disks(
5359
pool_with_unused_512B_disk: Pool,
54-
unused_512B_disks: dict[Host, list[Host.BlockDeviceInfo]],
60+
lvm_disk_paths: dict[Host, list[str]],
5561
provisioning_type: str,
5662
) -> Generator[None, None, None]:
5763
"""
@@ -66,12 +72,8 @@ def lvm_disks(
6672
"""
6773
hosts = pool_with_unused_512B_disk.hosts
6874

69-
@functools.cache
70-
def host_devices(host: Host) -> list[str]:
71-
return [disk.path for disk in unused_512B_disks[host][0:1]]
72-
7375
for host in hosts:
74-
devices = host_devices(host)
76+
devices = lvm_disk_paths[host]
7577
for device in devices:
7678
try:
7779
host.ssh(f'pvcreate -ff -y {device}')
@@ -94,7 +96,7 @@ def host_devices(host: Host) -> list[str]:
9496

9597
for host in hosts:
9698
host.ssh(f'vgremove -f {GROUP_NAME}')
97-
for device in host_devices(host):
99+
for device in lvm_disk_paths[host]:
98100
host.ssh(f'pvremove {device}')
99101

100102
@pytest.fixture(scope="package")

0 commit comments

Comments
 (0)