Skip to content

Commit 38026d3

Browse files
committed
Temporary fist tests for resize
Signed-off-by: Damien Thenot <[email protected]>
1 parent 3410d57 commit 38026d3

File tree

3 files changed

+111
-1
lines changed

3 files changed

+111
-1
lines changed

conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ def nfs_iso_sr(host, nfs_iso_device_config):
750750
# teardown
751751
sr.forget()
752752

753-
@pytest.fixture(scope='module')
753+
@pytest.fixture(scope='function')
754754
def exit_on_fistpoint(host):
755755
from lib.fistpoint import FistPoint
756756
logging.info(">> Enabling exit on fistpoint")

tests/storage/ext/test_ext_sr.py

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

3+
import logging
4+
35
from lib.common import vm_image, wait_for
6+
from lib.fistpoint import FistPoint
7+
from lib.vdi import VDI
48
from tests.storage import try_to_create_sr_with_missing_device, vdi_is_open
59

610
# Requirements:
@@ -55,6 +59,47 @@ def test_snapshot(self, vm_on_ext_sr):
5559

5660
# *** tests with reboots (longer tests).
5761

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

tests/storage/lvm/test_lvm_sr.py

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

3+
import logging
4+
5+
from lib.commands import SSHCommandFailed
36
from lib.common import vm_image, wait_for
7+
from lib.fistpoint import FistPoint
8+
from lib.vdi import VDI
49
from tests.storage import try_to_create_sr_with_missing_device, vdi_is_open
510

611
# Requirements:
@@ -53,6 +58,66 @@ def test_snapshot(self, vm_on_lvm_sr):
5358
finally:
5459
vm.shutdown(verify=True)
5560

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

58123
@pytest.mark.reboot

0 commit comments

Comments
 (0)