Skip to content

Commit f84c8bc

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 f84c8bc

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/storage/linstor/conftest.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,53 @@ 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+
@pytest.fixture(scope='module')
142+
def join_host_to_pool(host, hostB1):
143+
assert len(hostB1.pool.hosts) == 1, "This test requires second host to be a single host"
144+
original_pool = hostB1.pool
145+
logging.info("Joining host %s to pool %s", hostB1, host)
146+
hostB1.join_pool(host.pool)
147+
yield
148+
host.pool.eject_host(hostB1)
149+
hostB1.pool = original_pool
150+
151+
@pytest.fixture(scope='module')
152+
def vm_with_reboot_check(vm_on_linstor_sr):
153+
vm = vm_on_linstor_sr
154+
vm.start()
155+
vm.wait_for_os_booted()
156+
yield vm
157+
vm.shutdown(verify=True)
158+
# Ensure VM is able to start and shutdown on modified SR
159+
vm.start()
160+
vm.wait_for_os_booted()
161+
vm.shutdown(verify=True)

0 commit comments

Comments
 (0)