Skip to content

Commit 14deeb0

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 2118545 commit 14deeb0

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

tests/storage/linstor/test_linstor_sr.py

Lines changed: 58 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,63 @@ 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+
This test demonstrates online expansion of a LINSTOR SR while a VM is actively running on it.
94+
95+
It identifies hosts within the same pool, detects free raw disks, and expands the LVM to grow the SR.
96+
A VM is started before the expansion, and its functionality is verified through a shutdown and restart
97+
after the expansion completes successfully.
98+
"""
99+
sr = linstor_sr
100+
vm = vm_on_linstor_sr
101+
vm.start()
102+
sr_size = sr.pool.master.xe('sr-param-get', {'uuid': sr.uuid, 'param-name': 'physical-size'})
103+
resized = False
104+
disks = []
105+
for h in sr.pool.hosts:
106+
logging.info("Checking on {}".format(h.hostname_or_ip))
107+
available_disks = h.available_disks()
108+
# We need the disk to be "raw" (non LVM_member etc) to use
109+
available_disks = [disk for disk in available_disks if h.raw_disk_is_available(disk)]
110+
expansion_sr_disk = pytestconfig.getoption("expansion_sr_disk")
111+
if expansion_sr_disk:
112+
assert len(expansion_sr_disk) == 1, "This test requires only one --expansion-sr-disk parameter"
113+
if "auto" == expansion_sr_disk[0]:
114+
disks = available_disks
115+
else:
116+
assert expansion_sr_disk[0] in available_disks, "The expansion-sr-disk seems unavailable"
117+
disks = expansion_sr_disk
118+
else:
119+
disks = available_disks
120+
for disk in disks:
121+
logging.info("Found Disk {}".format(disk))
122+
device = '/dev/' + disk
123+
try:
124+
h.ssh(['pvcreate', device])
125+
h.ssh(['vgextend', GROUP_NAME, device])
126+
if provisioning_type == "thin":
127+
h.ssh(['lvextend', '-l', '+100%FREE', storage_pool_name])
128+
else: # Needed service restart for thick pool sr scan
129+
h.ssh('systemctl restart linstor-satellite.service')
130+
resized = True
131+
logging.info("Successfully expanded LVM on %s with %s", h.hostname_or_ip, device)
132+
except SSHCommandFailed as e:
133+
raise e
134+
135+
# Need to ensure that linstor is healthy/up-to-date before moving ahead.
136+
time.sleep(30) # Wait time for Linstor node communications to restore.
137+
sr.scan()
138+
new_sr_size = sr.pool.master.xe('sr-param-get', {'uuid': sr.uuid, 'param-name': 'physical-size'})
139+
assert int(new_sr_size) > int(sr_size) and resized is True, \
140+
f"Expected SR size to increase but got old size: {sr_size}, new size: {new_sr_size}"
141+
logging.info("SR expansion completed")
142+
vm.shutdown(verify=True)
143+
# Ensure VM is able to start and shutdown on expanded SR
144+
self.test_start_and_shutdown_VM(vm)
145+
89146
# *** tests with reboots (longer tests).
90147

91148
@pytest.mark.reboot

0 commit comments

Comments
 (0)