Skip to content

Commit ebe1b0e

Browse files
committed
Temporary fist tests for resize
1 parent 6541c56 commit ebe1b0e

File tree

3 files changed

+109
-1
lines changed

3 files changed

+109
-1
lines changed

conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ def nfs_iso_sr(host, nfs_iso_device_config):
742742
# teardown
743743
sr.forget()
744744

745-
@pytest.fixture(scope='module')
745+
@pytest.fixture(scope='function')
746746
def exit_on_fistpoint(host):
747747
from lib.fistpoint import FistPoint
748748
logging.info(">> Enabling exit on fistpoint")

tests/storage/ext/test_ext_sr.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import pytest
2+
import logging
23
from lib.common import wait_for, vm_image
4+
from lib.fistpoint import FistPoint
5+
from lib.vdi import VDI
36
from tests.storage import try_to_create_sr_with_missing_device, vdi_is_open
47

58
# Requirements:
@@ -54,6 +57,47 @@ def test_snapshot(self, vm_on_ext_sr):
5457

5558
# *** tests with reboots (longer tests).
5659

60+
@pytest.mark.small_vm
61+
@pytest.mark.big_vm
62+
def test_blktap_activate_failure(self, vm_on_ext_sr):
63+
from lib.fistpoint import FistPoint
64+
vm = vm_on_ext_sr
65+
with FistPoint(vm.host, "blktap_activate_inject_failure"):
66+
try:
67+
vm.start()
68+
vm.shutdown(force=True)
69+
except Exception as e:
70+
logging.info(f"Expected failure {e}")
71+
72+
@pytest.mark.small_vm
73+
@pytest.mark.big_vm
74+
def test_resize(self, vm_on_ext_sr):
75+
vm = vm_on_ext_sr
76+
vdi = VDI(vm.vdi_uuids()[0], host=vm.host)
77+
old_size = vdi.size()
78+
new_size = old_size + (1 * 1024 * 1024 * 1024) # Adding a 1GiB to size
79+
80+
vdi.resize(new_size)
81+
82+
assert vdi.size() == new_size
83+
84+
@pytest.mark.small_vm
85+
@pytest.mark.big_vm
86+
def test_failing_resize(self, host, ext_sr, vm_on_ext_sr, exit_on_fistpoint):
87+
vm = vm_on_ext_sr
88+
vdi = VDI(vm.vdi_uuids()[0], host=vm.host)
89+
old_size = vdi.size()
90+
new_size = old_size + (1 * 1024 * 1024 * 1024) # Adding a 1GiB to size
91+
92+
with FistPoint(vm.host, "LVHDRT_inflate_after_setSize"):
93+
try:
94+
vdi.resize(new_size)
95+
except:
96+
logging.info(f"Launching SR scan for {ext_sr} after failure")
97+
host.xe("sr-scan", {"uuid": ext_sr})
98+
99+
assert vdi.size() == new_size
100+
57101
@pytest.mark.reboot
58102
@pytest.mark.small_vm
59103
def test_reboot(self, host, ext_sr, vm_on_ext_sr):

tests/storage/lvm/test_lvm_sr.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import pytest
2+
import logging
3+
from lib.commands import SSHCommandFailed
24
from lib.common import wait_for, vm_image
5+
from lib.vdi import VDI
6+
from lib.fistpoint import FistPoint
37
from tests.storage import try_to_create_sr_with_missing_device, vdi_is_open
48

59
# Requirements:
@@ -52,6 +56,66 @@ def test_snapshot(self, vm_on_lvm_sr):
5256
finally:
5357
vm.shutdown(verify=True)
5458

59+
@pytest.mark.small_vm
60+
@pytest.mark.big_vm
61+
def test_failing_resize_on_inflate_after_setSize(self, host, lvm_sr, vm_on_lvm_sr, exit_on_fistpoint):
62+
vm = vm_on_lvm_sr
63+
lvinflate = ""
64+
need_rescan = False
65+
vdi = VDI(vm.vdi_uuids()[0], host=vm.host)
66+
new_size = vdi.size() + (1 * 1024 * 1024 * 1024) # Adding a 1GiB to size
67+
68+
with FistPoint(vm.host, "LVHDRT_inflate_after_setSize"):
69+
try:
70+
vdi.resize(new_size)
71+
except SSHCommandFailed as e:
72+
logging.info(e)
73+
need_rescan = True
74+
75+
assert need_rescan, "Resize did not make an error"
76+
lvlist = host.lvs(f"VG_XenStorage-{lvm_sr.uuid}")
77+
for lv in lvlist:
78+
if lv.startswith("inflate_"):
79+
logging.info(f"Found inflate journal following error: {lv}")
80+
lvinflate = lv
81+
82+
logging.info(f"Launching SR scan for {lvm_sr.uuid} to resolve failure")
83+
try:
84+
host.xe("sr-scan", {"uuid": lvm_sr.uuid})
85+
except SSHCommandFailed as e:
86+
assert False, f"Failing to scan following a inflate error {e}"
87+
assert not lvinflate in host.lvs(f"VG_XenStorage-{lvm_sr.uuid}"), "Inflate journal still exist following the scan"
88+
89+
@pytest.mark.small_vm
90+
@pytest.mark.big_vm
91+
def test_failing_resize_on_inflate_after_setSizePhys(self, host, lvm_sr, vm_on_lvm_sr, exit_on_fistpoint):
92+
vm = vm_on_lvm_sr
93+
lvinflate = ""
94+
need_rescan = False
95+
vdi = VDI(vm.vdi_uuids()[0], host=vm.host)
96+
new_size = vdi.size() + (1 * 1024 * 1024 * 1024) # Adding a 1GiB to size
97+
98+
with FistPoint(vm.host, "LVHDRT_inflate_after_setSizePhys"):
99+
try:
100+
vdi.resize(new_size)
101+
except SSHCommandFailed as e:
102+
logging.info(e)
103+
need_rescan = True
104+
105+
assert need_rescan, "Resize did not make an error"
106+
lvlist = host.lvs(f"VG_XenStorage-{lvm_sr.uuid}")
107+
for lv in lvlist:
108+
if lv.startswith("inflate_"):
109+
logging.info(f"Found inflate journal following error: {lv}")
110+
lvinflate = lv
111+
112+
logging.info(f"Launching SR scan for {lvm_sr.uuid} to resolve failure")
113+
try:
114+
host.xe("sr-scan", {"uuid": lvm_sr.uuid})
115+
except SSHCommandFailed as e:
116+
assert False, f"Failing to scan following a inflate error {e}"
117+
assert not lvinflate in host.lvs(f"VG_XenStorage-{lvm_sr.uuid}"), "Inflate journal still exist following the scan"
118+
55119
# *** tests with reboots (longer tests).
56120

57121
@pytest.mark.reboot

0 commit comments

Comments
 (0)