Skip to content

Commit f2a8994

Browse files
Added test_linstor_sr_pool_update for pool update with VM availability check.
- Uses `@pytest.mark.upgrade_test` to mark need of upgrade during the test - Updates of all hosts in a LINSTOR SR pool (starting with the master) - Reboots updated hosts - Verifies VM can start and shutdown successfully on each host after update - Ensures SR remains usable throughout the process Signed-off-by: Rushikesh Jadhav <[email protected]>
1 parent a4eb408 commit f2a8994

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/storage/linstor/test_linstor_sr.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,56 @@ def test_linstor_missing(self, linstor_sr, host):
131131
if not linstor_installed:
132132
host.yum_install([LINSTOR_PACKAGE])
133133

134+
@pytest.mark.reboot
135+
@pytest.mark.small_vm
136+
@pytest.mark.upgrade_test
137+
def test_linstor_sr_pool_update(self, linstor_sr, vm_on_linstor_sr):
138+
"""
139+
Perform update on the Linstor SR pool hosts while ensuring VM availability.
140+
1. Identify all hosts in the SR pool and order them with the master first.
141+
2. Update all hosts if updates are available.
142+
3. Reboot all hosts.
143+
4. Sequentially ensure that the VM can start on all hosts.
144+
"""
145+
import concurrent.futures, threading
146+
147+
sr = linstor_sr
148+
vm = vm_on_linstor_sr
149+
updates_applied = []
150+
updates_lock = threading.Lock()
151+
152+
# Sort hosts so that pool master is first (optional)
153+
hosts = sorted(sr.pool.hosts, key=lambda h: h != sr.pool.master)
154+
155+
# RPU is disabled for pools with XOSTOR SRs.
156+
# LINSTOR expects that we always use satellites and controllers with the same version on all hosts.
157+
def install_updates_on(host):
158+
logging.info("Checking on host %s", host.hostname_or_ip)
159+
if host.has_updates(enablerepo="xcp-ng-linstor-testing"):
160+
host.install_updates(enablerepo="xcp-ng-linstor-testing")
161+
with updates_lock:
162+
updates_applied.append(host)
163+
else:
164+
logging.info("No updates available for host %s", host.hostname_or_ip)
165+
166+
with concurrent.futures.ThreadPoolExecutor() as executor:
167+
executor.map(install_updates_on, hosts)
168+
169+
# Reboot updated hosts
170+
def reboot_updated(host):
171+
host.reboot(verify=True)
172+
173+
with concurrent.futures.ThreadPoolExecutor() as executor:
174+
executor.map(reboot_updated, updates_applied)
175+
176+
# Ensure VM is able to boot on all the hosts
177+
for h in hosts:
178+
vm.start(on=h.uuid)
179+
vm.wait_for_os_booted()
180+
vm.shutdown(verify=True)
181+
182+
sr.scan()
183+
134184
# *** End of tests with reboots
135185

136186
# --- Test diskless resources --------------------------------------------------

0 commit comments

Comments
 (0)