Skip to content

Commit 083151b

Browse files
committed
test_*_sr: fix test_snapshot (x)fail not to contaminate subsequent tests
All SR's test_snapshot take a stopped VM from vm_on_*_sr fixture. Then they start it, and hopefully stop it if everything went well. Now if something went bad the shutdown would never be requested. If other tests are then run after a failure (which currently requires using `--maxfail` to overrule the config file), or if such a test is marked xfail (like the first public prototype for zfs-ng), subsequent tests chained by pytest would be launched with a VM wrongly started, and fail for this reason, which is bad. Signed-off-by: Yann Dirson <[email protected]>
1 parent 3183fc5 commit 083151b

File tree

10 files changed

+50
-30
lines changed

10 files changed

+50
-30
lines changed

tests/storage/cephfs/test_cephfs_sr.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ def test_start_and_shutdown_VM(self, vm_on_cephfs_sr):
6262
def test_snapshot(self, vm_on_cephfs_sr):
6363
vm = vm_on_cephfs_sr
6464
vm.start()
65-
vm.wait_for_os_booted()
66-
vm.test_snapshot_on_running_vm()
67-
vm.shutdown(verify=True)
65+
try:
66+
vm.wait_for_os_booted()
67+
vm.test_snapshot_on_running_vm()
68+
finally:
69+
vm.shutdown(verify=True)
6870

6971
# *** tests with reboots (longer tests).
7072

tests/storage/ext/test_ext_sr.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ def test_start_and_shutdown_VM(self, vm_on_ext_sr):
4646
def test_snapshot(self, vm_on_ext_sr):
4747
vm = vm_on_ext_sr
4848
vm.start()
49-
vm.wait_for_os_booted()
50-
vm.test_snapshot_on_running_vm()
51-
vm.shutdown(verify=True)
49+
try:
50+
vm.wait_for_os_booted()
51+
vm.test_snapshot_on_running_vm()
52+
finally:
53+
vm.shutdown(verify=True)
5254

5355
# *** tests with reboots (longer tests).
5456

tests/storage/glusterfs/test_glusterfs_sr.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ def test_start_and_shutdown_VM(self, vm_on_glusterfs_sr):
6161
def test_snapshot(self, vm_on_glusterfs_sr):
6262
vm = vm_on_glusterfs_sr
6363
vm.start()
64-
vm.wait_for_os_booted()
65-
vm.test_snapshot_on_running_vm()
66-
vm.shutdown(verify=True)
64+
try:
65+
vm.wait_for_os_booted()
66+
vm.test_snapshot_on_running_vm()
67+
finally:
68+
vm.shutdown(verify=True)
6769

6870
def test_volume_stopped(self, host, glusterfs_sr):
6971
sr = glusterfs_sr

tests/storage/linstor/test_linstor_sr.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ def test_start_and_shutdown_VM(self, vm_on_linstor_sr):
7272
def test_snapshot(self, vm_on_linstor_sr):
7373
vm = vm_on_linstor_sr
7474
vm.start()
75-
vm.wait_for_os_booted()
76-
vm.test_snapshot_on_running_vm()
77-
vm.shutdown(verify=True)
75+
try:
76+
vm.wait_for_os_booted()
77+
vm.test_snapshot_on_running_vm()
78+
finally:
79+
vm.shutdown(verify=True)
7880

7981
# *** tests with reboots (longer tests).
8082

tests/storage/lvm/test_lvm_sr.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ def test_start_and_shutdown_VM(self, vm_on_lvm_sr):
4646
def test_snapshot(self, vm_on_lvm_sr):
4747
vm = vm_on_lvm_sr
4848
vm.start()
49-
vm.wait_for_os_booted()
50-
vm.test_snapshot_on_running_vm()
51-
vm.shutdown(verify=True)
49+
try:
50+
vm.wait_for_os_booted()
51+
vm.test_snapshot_on_running_vm()
52+
finally:
53+
vm.shutdown(verify=True)
5254

5355
# *** tests with reboots (longer tests).
5456

tests/storage/lvmoiscsi/test_lvmoiscsi_sr.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ def test_start_and_shutdown_VM(self, vm_on_lvmoiscsi_sr):
4444
def test_snapshot(self, vm_on_lvmoiscsi_sr):
4545
vm = vm_on_lvmoiscsi_sr
4646
vm.start()
47-
vm.wait_for_os_booted()
48-
vm.test_snapshot_on_running_vm()
49-
vm.shutdown(verify=True)
47+
try:
48+
vm.wait_for_os_booted()
49+
vm.test_snapshot_on_running_vm()
50+
finally:
51+
vm.shutdown(verify=True)
5052

5153
# *** tests with reboots (longer tests).
5254

tests/storage/moosefs/test_moosefs_sr.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ def test_start_and_shutdown_VM(self, vm_on_moosefs_sr):
6666
def test_snapshot(self, vm_on_moosefs_sr):
6767
vm = vm_on_moosefs_sr
6868
vm.start()
69-
vm.wait_for_os_booted()
70-
vm.test_snapshot_on_running_vm()
71-
vm.shutdown(verify=True)
69+
try:
70+
vm.wait_for_os_booted()
71+
vm.test_snapshot_on_running_vm()
72+
finally:
73+
vm.shutdown(verify=True)
7274

7375
def test_moosefs_missing_client_scan_fails(self, host, moosefs_sr):
7476
sr = moosefs_sr

tests/storage/nfs/test_nfs_sr.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ def test_start_and_shutdown_VM(self, vm_on_nfs_sr):
3737
def test_snapshot(self, vm_on_nfs_sr):
3838
vm = vm_on_nfs_sr
3939
vm.start()
40-
vm.wait_for_os_booted()
41-
vm.test_snapshot_on_running_vm()
42-
vm.shutdown(verify=True)
40+
try:
41+
vm.wait_for_os_booted()
42+
vm.test_snapshot_on_running_vm()
43+
finally:
44+
vm.shutdown(verify=True)
4345

4446
# *** tests with reboots (longer tests).
4547

tests/storage/xfs/test_xfs_sr.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ def test_start_and_shutdown_VM(self, vm_on_xfs_sr):
6262
def test_snapshot(self, vm_on_xfs_sr):
6363
vm = vm_on_xfs_sr
6464
vm.start()
65-
vm.wait_for_os_booted()
66-
vm.test_snapshot_on_running_vm()
67-
vm.shutdown(verify=True)
65+
try:
66+
vm.wait_for_os_booted()
67+
vm.test_snapshot_on_running_vm()
68+
finally:
69+
vm.shutdown(verify=True)
6870

6971
# *** tests with reboots (longer tests).
7072

tests/storage/zfs/test_zfs_sr.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ def test_start_and_shutdown_VM(self, vm_on_zfs_sr):
6464
def test_snapshot(self, vm_on_zfs_sr):
6565
vm = vm_on_zfs_sr
6666
vm.start()
67-
vm.wait_for_os_booted()
68-
vm.test_snapshot_on_running_vm()
69-
vm.shutdown(verify=True)
67+
try:
68+
vm.wait_for_os_booted()
69+
vm.test_snapshot_on_running_vm()
70+
finally:
71+
vm.shutdown(verify=True)
7072

7173
# *** tests with reboots (longer tests).
7274

0 commit comments

Comments
 (0)