Skip to content

Commit ebb1e7d

Browse files
Added test_linstor_sr_fail_host to simulate a crash of a non-master host.
- Chooses a host within a LINSTOR SR pool and simulate crash using sysrq-trigger. - Verifies VM boot and shutdown on all remaining hosts during the outage, and confirms recovery of the failed host for VM placement post-reboot. - Ensures SR scan consistency post-recovery. Signed-off-by: Rushikesh Jadhav <rushikesh7@gmail.com>
1 parent 12e9d98 commit ebb1e7d

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/storage/linstor/test_linstor_sr.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22

33
import logging
4+
import random
45
import time
56

67
from lib.commands import SSHCommandFailed
@@ -133,6 +134,47 @@ def test_linstor_missing(self, linstor_sr, host):
133134
if not linstor_installed:
134135
host.yum_install([LINSTOR_PACKAGE])
135136

137+
@pytest.mark.reboot
138+
@pytest.mark.small_vm
139+
def test_linstor_sr_fail_host(self, linstor_sr, host, vm_on_linstor_sr):
140+
"""
141+
Fail non master host from the same pool Linstor SR.
142+
Ensure that VM is able to boot and shutdown on all hosts.
143+
"""
144+
sr = linstor_sr
145+
vm = vm_on_linstor_sr
146+
# Ensure that its a single host pool and not multi host pool
147+
assert len(host.pool.hosts) > 2, "This test requires Pool to have more than 2 hosts"
148+
149+
# Remove master from hosts list to avoid xapi calls failure
150+
hosts = list(sr.pool.hosts)
151+
hosts.remove(sr.pool.master)
152+
# Evacuate the node to be deleted
153+
try:
154+
random_host = random.choice(hosts) # TBD: Choose Linstor Diskful node
155+
logging.info("Working on %s", random_host.hostname_or_ip)
156+
random_host.ssh(['echo', 'c', '>', '/proc/sysrq-trigger'])
157+
except Exception as e:
158+
logging.info("Host %s could be crashed with output %s.", random_host.hostname_or_ip, e.stdout)
159+
160+
# Ensure that VM is able to start on all hosts except failed one
161+
for h in sr.pool.hosts:
162+
logging.info("Checking VM on host %s", h.hostname_or_ip)
163+
if h.hostname_or_ip != random_host.hostname_or_ip:
164+
vm.start(on=h.uuid)
165+
vm.wait_for_os_booted()
166+
vm.shutdown(verify=True)
167+
168+
# Wait for radom_host to come online
169+
wait_for(random_host.is_enabled, "Wait for crashed host enabled", timeout_secs=30 * 60)
170+
171+
# Ensure that the VM is able to run on crashed host as well.
172+
vm.start(on=random_host.uuid)
173+
vm.wait_for_os_booted()
174+
vm.shutdown(verify=True)
175+
176+
sr.scan()
177+
136178
# *** End of tests with reboots
137179

138180
# --- Test diskless resources --------------------------------------------------

0 commit comments

Comments
 (0)