Skip to content

Commit d6691fc

Browse files
committed
Add a docstring for fistpoint
Signed-off-by: Damien Thenot <[email protected]>
1 parent 38026d3 commit d6691fc

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

lib/fistpoint.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
11
import logging
2-
from typing import Final
32

43
from lib.host import Host
54

5+
from typing import Final
6+
67
FISTPOINT_DIR: Final = "/tmp"
78
LVHDRT_EXIT_FIST: Final = "fist_LVHDRT_exit"
89

10+
911
class FistPoint:
12+
"""
13+
A fistpoint is an action that you can enable in the smapi for tests.
14+
15+
It allows for example, add a sleep at some point or raise an exception.
16+
For example:
17+
```
18+
with FistPoint(vm.host, "blktap_activate_inject_failure"):
19+
try:
20+
vm.start()
21+
vm.shutdown(force=True)
22+
except Exception as e:
23+
logging.info(f"Expected failure {e}")
24+
```
25+
Activating the fistpoint `blktap_activate_inject_failure` mean that the VDI
26+
activation will fail. This fistpoint always raise an exception but most
27+
fistpoint just add a sleep at a point in the code.
28+
Using the fixture `exit_on_fistpoint` make all fistpoints raise an
29+
exception instead by enabling a special fistpoint called `fist_LVHDRT_exit`
30+
"""
31+
1032
fistpointName: str
1133

1234
def __init__(self, host: Host, name: str):

tests/storage/ext/test_ext_sr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def test_failing_resize(self, host, ext_sr, vm_on_ext_sr, exit_on_fistpoint):
9494
with FistPoint(vm.host, "LVHDRT_inflate_after_setSize"):
9595
try:
9696
vdi.resize(new_size)
97-
except:
97+
except Exception:
9898
logging.info(f"Launching SR scan for {ext_sr} after failure")
9999
host.xe("sr-scan", {"uuid": ext_sr})
100100

tests/storage/lvm/test_lvm_sr.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ def test_failing_resize_on_inflate_after_setSize(self, host, lvm_sr, vm_on_lvm_s
8686
host.xe("sr-scan", {"uuid": lvm_sr.uuid})
8787
except SSHCommandFailed as e:
8888
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"
89+
assert lvinflate not in host.lvs(f"VG_XenStorage-{lvm_sr.uuid}"), \
90+
"Inflate journal still exist following the scan"
9091

9192
@pytest.mark.small_vm
9293
@pytest.mark.big_vm
@@ -116,7 +117,8 @@ def test_failing_resize_on_inflate_after_setSizePhys(self, host, lvm_sr, vm_on_l
116117
host.xe("sr-scan", {"uuid": lvm_sr.uuid})
117118
except SSHCommandFailed as e:
118119
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+
assert lvinflate not in host.lvs(f"VG_XenStorage-{lvm_sr.uuid}"), \
121+
"Inflate journal still exist following the scan"
120122

121123
# *** tests with reboots (longer tests).
122124

0 commit comments

Comments
 (0)