Skip to content

Commit 739305d

Browse files
Added fixtures to use in test_linstor_sr_expand_disk and test_linstor_sr_expand_host
Signed-off-by: Rushikesh Jadhav <[email protected]>
1 parent e32681f commit 739305d

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

tests/storage/linstor/conftest.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,57 @@ def vm_on_linstor_sr(host, linstor_sr, vm_ref):
109109
yield vm
110110
logging.info("<< Destroy VM")
111111
vm.destroy(verify=True)
112+
113+
@pytest.fixture(scope='module')
114+
def prepare_linstor_packages(hostB1):
115+
if not hostB1.is_package_installed(LINSTOR_PACKAGE):
116+
logging.info("Installing %s on host %s", LINSTOR_PACKAGE, hostB1)
117+
hostB1.yum_install([LINSTOR_RELEASE_PACKAGE])
118+
hostB1.yum_install([LINSTOR_PACKAGE], enablerepo="xcp-ng-linstor-testing")
119+
# Needed because the linstor driver is not in the xapi sm-plugins list
120+
# before installing the LINSTOR packages.
121+
hostB1.ssh(["systemctl", "restart", "multipathd"])
122+
hostB1.restart_toolstack(verify=True)
123+
yield
124+
hostB1.yum_remove([LINSTOR_PACKAGE]) # Package cleanup
125+
126+
@pytest.fixture(scope='module')
127+
def setup_lvm_on_host(hostB1):
128+
# Ensure that the host has disks available to use, we do not care about disks symmetry across pool
129+
# We need the disk to be "raw" (non LVM_member etc) to use
130+
disks = [d for d in hostB1.available_disks() if hostB1.raw_disk_is_available(d)]
131+
assert disks, "hostB1 requires at least one raw disk"
132+
devices = [f"/dev/{d}" for d in disks]
133+
134+
for disk in devices:
135+
logging.info("Found Disk %s", disk)
136+
hostB1.ssh(['pvcreate', disk])
137+
hostB1.ssh(['vgcreate', GROUP_NAME] + devices)
138+
139+
yield "linstor_group", devices
140+
141+
# TODO: Getting handled in lvm_disks
142+
#hostB1.ssh(['vgremove', '-y', GROUP_NAME])
143+
#hostB1.ssh(['pvremove', '-y'] + devices)
144+
145+
@pytest.fixture(scope='module')
146+
def join_host_to_pool(host, hostB1):
147+
assert len(hostB1.pool.hosts) == 1, "This test requires second host to be a single host"
148+
original_pool = hostB1.pool
149+
logging.info("Joining host %s to pool %s", hostB1, host)
150+
hostB1.join_pool(host.pool)
151+
yield
152+
host.pool.eject_host(hostB1)
153+
hostB1.pool = original_pool
154+
155+
@pytest.fixture(scope='module')
156+
def vm_with_reboot_check(vm_on_linstor_sr):
157+
vm = vm_on_linstor_sr
158+
vm.start()
159+
vm.wait_for_os_booted()
160+
yield vm
161+
vm.shutdown(verify=True)
162+
# Ensure VM is able to start and shutdown on modified SR
163+
vm.start()
164+
vm.wait_for_os_booted()
165+
vm.shutdown(verify=True)

0 commit comments

Comments
 (0)