From ddd9ef3a4fab1eed3ed7c32900fc7f9474f2929b Mon Sep 17 00:00:00 2001 From: Ryan Moeller Date: Tue, 10 Mar 2020 14:00:56 -0400 Subject: ZTS: Add a failsafe callback to run after each test Tests that get killed do not have an opportunity to clean up. There are many bad states this can leave the system in, but of particular gravity is when zinject has been used to induce bad behavior for one or more of the test disks. Create a failsafe mechanism in test-runner.py that runs a callback script after every test. The script is common to all tests so all tests benefit from the protection. Add an obligatory `zinject -c all` to clear all zinject state after every test case is run. Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Signed-off-by: Ryan Moeller Closes #10096 --- tests/zfs-tests/callbacks/Makefile.am | 1 + tests/zfs-tests/callbacks/zfs_failsafe.ksh | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100755 tests/zfs-tests/callbacks/zfs_failsafe.ksh (limited to 'tests/zfs-tests/callbacks') diff --git a/tests/zfs-tests/callbacks/Makefile.am b/tests/zfs-tests/callbacks/Makefile.am index 30e847241..512a737bb 100644 --- a/tests/zfs-tests/callbacks/Makefile.am +++ b/tests/zfs-tests/callbacks/Makefile.am @@ -1,5 +1,6 @@ pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/callbacks dist_pkgdata_SCRIPTS = \ + zfs_failsafe.ksh \ zfs_dbgmsg.ksh \ zfs_dmesg.ksh \ zfs_mmp.ksh diff --git a/tests/zfs-tests/callbacks/zfs_failsafe.ksh b/tests/zfs-tests/callbacks/zfs_failsafe.ksh new file mode 100755 index 000000000..0d14df701 --- /dev/null +++ b/tests/zfs-tests/callbacks/zfs_failsafe.ksh @@ -0,0 +1,8 @@ +#!/bin/ksh + +# Commands to perform failsafe-critical cleanup after a test is killed. +# +# This should only be used to ensure the system is restored to a functional +# state in the event of tests being killed (preventing normal cleanup). + +zinject -c all -- cgit v1.2.3