Skip to content

Commit 5fec55c

Browse files
tests/storage/linstor: Implemented 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 5fec55c

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

tests/storage/linstor/test_linstor_sr.py

Lines changed: 52 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,57 @@ 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("* I'm on {}*".format(h.hostname_or_ip))
103+
available_disks = h.available_disks()
104+
exapnsion_sr_disk = pytestconfig.getoption("expansion_sr_disk")
105+
if exapnsion_sr_disk:
106+
assert len(exapnsion_sr_disk) == 1, "This test requires only one --expansion-sr-disk parameter"
107+
if "auto" == exapnsion_sr_disk[0]:
108+
disks = available_disks
109+
else:
110+
assert exapnsion_sr_disk[0] in available_disks, "The expansion-sr-disk seems unavailable"
111+
disks = exapnsion_sr_disk
112+
else:
113+
disks = available_disks
114+
for disk in disks:
115+
logging.info("* Disk is {}*".format(disk))
116+
device = '/dev/' + disk
117+
try:
118+
h.ssh(['pvcreate', '-ff', '-y', device])
119+
h.ssh(['vgextend', GROUP_NAME, device])
120+
if provisioning_type == "thin":
121+
h.ssh(['lvextend', '-l', '+100%FREE', storage_pool_name])
122+
else: # Needed service restart for thick pool sr scan
123+
h.ssh('systemctl restart linstor-satellite.service')
124+
resized = True
125+
logging.info(f"Successfully expanded LVM on {h.hostname_or_ip} : {device}")
126+
except SSHCommandFailed as e:
127+
raise e
128+
129+
# Need to ensure that linstor is healthy/up-to-date before moving ahead.
130+
time.sleep(30) # Wait time for Linstor node communications to restore.
131+
sr.scan()
132+
new_sr_size = sr.pool.master.xe('sr-param-get', {'uuid': sr.uuid, 'param-name': 'physical-size'})
133+
assert int(new_sr_size) > int(sr_size) and resized is True, \
134+
f"Expected SR size to increase but got old size: {sr_size}, new size: {new_sr_size}"
135+
logging.info("* SR expansion completed *")
136+
vm.shutdown(verify=True)
137+
# Ensure VM is able to start and shutdown on expanded SR
138+
self.test_start_and_shutdown_VM(vm)
139+
89140
# *** tests with reboots (longer tests).
90141

91142
@pytest.mark.reboot

0 commit comments

Comments
 (0)