Skip to content

Commit cc4d36c

Browse files
rushikeshjadhavDatBewar
authored andcommitted
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 <rushikesh7@gmail.com>
1 parent ce9b679 commit cc4d36c

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

tests/storage/linstor/test_linstor_sr.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,56 @@ def test_linstor_missing(self, linstor_sr: SR, host: Host) -> None:
234234
if not linstor_installed:
235235
host.yum_install([LINSTOR_PACKAGE])
236236

237+
@pytest.mark.reboot
238+
@pytest.mark.small_vm
239+
@pytest.mark.upgrade_test
240+
def test_linstor_sr_pool_update(self, linstor_sr, vm_on_linstor_sr):
241+
"""
242+
Perform update on the Linstor SR pool hosts while ensuring VM availability.
243+
1. Identify all hosts in the SR pool and order them with the master first.
244+
2. Update all hosts if updates are available.
245+
3. Reboot all hosts.
246+
4. Sequentially ensure that the VM can start on all hosts.
247+
"""
248+
import concurrent.futures, threading
249+
250+
sr = linstor_sr
251+
vm = vm_on_linstor_sr
252+
updates_applied = []
253+
updates_lock = threading.Lock()
254+
255+
# Sort hosts so that pool master is first (optional)
256+
hosts = sorted(sr.pool.hosts, key=lambda h: h != sr.pool.master)
257+
258+
# RPU is disabled for pools with XOSTOR SRs.
259+
# LINSTOR expects that we always use satellites and controllers with the same version on all hosts.
260+
def install_updates_on(host):
261+
logging.info("Checking on host %s", host.hostname_or_ip)
262+
if host.has_updates(enablerepo="xcp-ng-linstor-testing"):
263+
host.install_updates(enablerepo="xcp-ng-linstor-testing")
264+
with updates_lock:
265+
updates_applied.append(host)
266+
else:
267+
logging.info("No updates available for host %s", host.hostname_or_ip)
268+
269+
with concurrent.futures.ThreadPoolExecutor() as executor:
270+
executor.map(install_updates_on, hosts)
271+
272+
# Reboot updated hosts
273+
def reboot_updated(host):
274+
host.reboot(verify=True)
275+
276+
with concurrent.futures.ThreadPoolExecutor() as executor:
277+
executor.map(reboot_updated, updates_applied)
278+
279+
# Ensure VM is able to boot on all the hosts
280+
for h in hosts:
281+
vm.start(on=h.uuid)
282+
vm.wait_for_os_booted()
283+
vm.shutdown(verify=True)
284+
285+
sr.scan()
286+
237287
# *** End of tests with reboots
238288

239289
# --- Test diskless resources --------------------------------------------------

0 commit comments

Comments
 (0)