Skip to content

Commit

Permalink
test_*_sr: fix test_snapshot (x)fail not to contaminate subsequent tests
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ydirson committed Mar 27, 2024
1 parent 3183fc5 commit 083151b
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 30 deletions.
8 changes: 5 additions & 3 deletions tests/storage/cephfs/test_cephfs_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ def test_start_and_shutdown_VM(self, vm_on_cephfs_sr):
def test_snapshot(self, vm_on_cephfs_sr):
vm = vm_on_cephfs_sr
vm.start()
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
vm.shutdown(verify=True)
try:
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
finally:
vm.shutdown(verify=True)

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

Expand Down
8 changes: 5 additions & 3 deletions tests/storage/ext/test_ext_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ def test_start_and_shutdown_VM(self, vm_on_ext_sr):
def test_snapshot(self, vm_on_ext_sr):
vm = vm_on_ext_sr
vm.start()
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
vm.shutdown(verify=True)
try:
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
finally:
vm.shutdown(verify=True)

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

Expand Down
8 changes: 5 additions & 3 deletions tests/storage/glusterfs/test_glusterfs_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ def test_start_and_shutdown_VM(self, vm_on_glusterfs_sr):
def test_snapshot(self, vm_on_glusterfs_sr):
vm = vm_on_glusterfs_sr
vm.start()
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
vm.shutdown(verify=True)
try:
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
finally:
vm.shutdown(verify=True)

def test_volume_stopped(self, host, glusterfs_sr):
sr = glusterfs_sr
Expand Down
8 changes: 5 additions & 3 deletions tests/storage/linstor/test_linstor_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ def test_start_and_shutdown_VM(self, vm_on_linstor_sr):
def test_snapshot(self, vm_on_linstor_sr):
vm = vm_on_linstor_sr
vm.start()
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
vm.shutdown(verify=True)
try:
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
finally:
vm.shutdown(verify=True)

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

Expand Down
8 changes: 5 additions & 3 deletions tests/storage/lvm/test_lvm_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ def test_start_and_shutdown_VM(self, vm_on_lvm_sr):
def test_snapshot(self, vm_on_lvm_sr):
vm = vm_on_lvm_sr
vm.start()
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
vm.shutdown(verify=True)
try:
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
finally:
vm.shutdown(verify=True)

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

Expand Down
8 changes: 5 additions & 3 deletions tests/storage/lvmoiscsi/test_lvmoiscsi_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ def test_start_and_shutdown_VM(self, vm_on_lvmoiscsi_sr):
def test_snapshot(self, vm_on_lvmoiscsi_sr):
vm = vm_on_lvmoiscsi_sr
vm.start()
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
vm.shutdown(verify=True)
try:
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
finally:
vm.shutdown(verify=True)

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

Expand Down
8 changes: 5 additions & 3 deletions tests/storage/moosefs/test_moosefs_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ def test_start_and_shutdown_VM(self, vm_on_moosefs_sr):
def test_snapshot(self, vm_on_moosefs_sr):
vm = vm_on_moosefs_sr
vm.start()
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
vm.shutdown(verify=True)
try:
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
finally:
vm.shutdown(verify=True)

def test_moosefs_missing_client_scan_fails(self, host, moosefs_sr):
sr = moosefs_sr
Expand Down
8 changes: 5 additions & 3 deletions tests/storage/nfs/test_nfs_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ def test_start_and_shutdown_VM(self, vm_on_nfs_sr):
def test_snapshot(self, vm_on_nfs_sr):
vm = vm_on_nfs_sr
vm.start()
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
vm.shutdown(verify=True)
try:
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
finally:
vm.shutdown(verify=True)

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

Expand Down
8 changes: 5 additions & 3 deletions tests/storage/xfs/test_xfs_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ def test_start_and_shutdown_VM(self, vm_on_xfs_sr):
def test_snapshot(self, vm_on_xfs_sr):
vm = vm_on_xfs_sr
vm.start()
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
vm.shutdown(verify=True)
try:
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
finally:
vm.shutdown(verify=True)

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

Expand Down
8 changes: 5 additions & 3 deletions tests/storage/zfs/test_zfs_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ def test_start_and_shutdown_VM(self, vm_on_zfs_sr):
def test_snapshot(self, vm_on_zfs_sr):
vm = vm_on_zfs_sr
vm.start()
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
vm.shutdown(verify=True)
try:
vm.wait_for_os_booted()
vm.test_snapshot_on_running_vm()
finally:
vm.shutdown(verify=True)

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

Expand Down

0 comments on commit 083151b

Please sign in to comment.