Skip to content

Commit 0f4b1dd

Browse files
tests/storage/linstor: Added test_linstor_sr_expand_disk to detect suitable disk(s) and expand LVM of Linstor SR across hosts.
The test: - Ensures `--expansion-sr-disk` disk(s) are available on the hosts. - Configures LVM onto it and integrates into Linstor SR pool. - Expands SR capacity and validates the increase. Signed-off-by: Rushikesh Jadhav <[email protected]>
1 parent 1dbef7e commit 0f4b1dd

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

tests/storage/linstor/test_linstor_sr.py

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33
import time
44

5-
from .conftest import LINSTOR_PACKAGE
5+
from .conftest import GROUP_NAME, LINSTOR_PACKAGE
66
from lib.commands import SSHCommandFailed
77
from lib.common import wait_for, vm_image
88
from tests.storage import vdi_is_open
@@ -86,6 +86,59 @@ def test_snapshot(self, vm_on_linstor_sr):
8686
finally:
8787
vm.shutdown(verify=True)
8888

89+
@pytest.mark.small_vm
90+
def test_linstor_sr_expand_disk(self, linstor_sr, provisioning_type, storage_pool_name,
91+
pytestconfig, vm_on_linstor_sr):
92+
"""
93+
Identify hosts within the same pool, detect free disks, create LVM, and integrate it into LINSTOR SR.
94+
"""
95+
sr = linstor_sr
96+
vm = vm_on_linstor_sr
97+
vm.start()
98+
sr_size = sr.pool.master.xe('sr-param-get', {'uuid': sr.uuid, 'param-name': 'physical-size'})
99+
resized = False
100+
disks = []
101+
for h in sr.pool.hosts:
102+
logging.info("Checking on {}".format(h.hostname_or_ip))
103+
available_disks = h.available_disks()
104+
# We need the disk to be "raw" (non LVM_member etc) to use
105+
available_disks = [disk for disk in available_disks if h.raw_disk_is_available(disk)]
106+
exapnsion_sr_disk = pytestconfig.getoption("expansion_sr_disk")
107+
if exapnsion_sr_disk:
108+
assert len(exapnsion_sr_disk) == 1, "This test requires only one --expansion-sr-disk parameter"
109+
if "auto" == exapnsion_sr_disk[0]:
110+
disks = available_disks
111+
else:
112+
assert exapnsion_sr_disk[0] in available_disks, "The expansion-sr-disk seems unavailable"
113+
disks = exapnsion_sr_disk
114+
else:
115+
disks = available_disks
116+
for disk in disks:
117+
logging.info("Found Disk {}".format(disk))
118+
device = '/dev/' + disk
119+
try:
120+
h.ssh(['pvcreate', '-ff', '-y', device])
121+
h.ssh(['vgextend', GROUP_NAME, device])
122+
if provisioning_type == "thin":
123+
h.ssh(['lvextend', '-l', '+100%FREE', storage_pool_name])
124+
else: # Needed service restart for thick pool sr scan
125+
h.ssh('systemctl restart linstor-satellite.service')
126+
resized = True
127+
logging.info("Successfully expanded LVM on %s with %s", h.hostname_or_ip, device)
128+
except SSHCommandFailed as e:
129+
raise e
130+
131+
# Need to ensure that linstor is healthy/up-to-date before moving ahead.
132+
time.sleep(30) # Wait time for Linstor node communications to restore.
133+
sr.scan()
134+
new_sr_size = sr.pool.master.xe('sr-param-get', {'uuid': sr.uuid, 'param-name': 'physical-size'})
135+
assert int(new_sr_size) > int(sr_size) and resized is True, \
136+
f"Expected SR size to increase but got old size: {sr_size}, new size: {new_sr_size}"
137+
logging.info("SR expansion completed")
138+
vm.shutdown(verify=True)
139+
# Ensure VM is able to start and shutdown on expanded SR
140+
self.test_start_and_shutdown_VM(vm)
141+
89142
# *** tests with reboots (longer tests).
90143

91144
@pytest.mark.reboot

0 commit comments

Comments
 (0)