|
1 | 1 | import pytest |
2 | 2 |
|
3 | 3 | import logging |
| 4 | +import random |
4 | 5 | import time |
5 | 6 |
|
6 | 7 | from lib.commands import SSHCommandFailed |
@@ -133,6 +134,47 @@ def test_linstor_missing(self, linstor_sr, host): |
133 | 134 | if not linstor_installed: |
134 | 135 | host.yum_install([LINSTOR_PACKAGE]) |
135 | 136 |
|
| 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 | + |
136 | 178 | # *** End of tests with reboots |
137 | 179 |
|
138 | 180 | # --- Test diskless resources -------------------------------------------------- |
|
0 commit comments