@@ -7,7 +7,7 @@ import re
import subprocess
import resource
import shutil
-from autotest.client import test, utils
+from autotest.client import test, utils
from autotest.client.shared import error
TEST_FILESYSTEM = os.getenv('TEST_FILESYSTEM')
@@ -409,13 +409,19 @@ class ubuntu_performance_fio(test.test):
self.get_sysinfo()
return
elif test_name == 'post-test-zfs-cleanup':
- utils.system('systemctl stop zed')
- utils.system('modprobe -r zfs')
- # No need to consider ubuntu-zfs package on P/T as they've been blacklisted
- utils.system('apt-get remove --yes --force-yes zfsutils-linux')
- # Remove .version for the test, in order to trigger setup() again if we want re-test it
- cmd = 'rm {}/.version'.format(self.srcdir)
- utils.system(cmd)
+ # Make sure there is no ZFS in use by any filesystem
+ try:
+ utils.system('df -t zfs &> /dev/null') # return 1 if not found
+ print("ZFS in use by filesystem, SKIP cleanup")
+ except error.CmdError:
+ print("Stop / unload / remove ZFS")
+ utils.system('systemctl stop zed')
+ utils.system('modprobe -r zfs')
+ # No need to consider ubuntu-zfs package on P/T as they've been blacklisted
+ utils.system('apt-get remove --yes --force-yes zfsutils-linux')
+ # Remove .version for the test, in order to trigger setup() again if we want re-test it
+ cmd = 'rm {}/.version'.format(self.srcdir)
+ utils.system(cmd)
return
#
@@ -1,6 +1,7 @@
#
#
from autotest.client import test, utils
+from autotest.client.shared import error
import platform
class ubuntu_performance_zfs_encryption(test.test):
@@ -39,13 +40,19 @@ class ubuntu_performance_zfs_encryption(test.test):
if test_name == 'setup':
return
elif test_name == 'post-test-zfs-cleanup':
- utils.system('systemctl stop zed')
- utils.system('modprobe -r zfs')
- # No need to consider ubuntu-zfs package on P/T as they've been blacklisted
- utils.system('apt-get remove --yes --force-yes zfsutils-linux')
- # Remove .version for the test, in order to trigger setup() again if we want re-test it
- cmd = 'rm {}/.version'.format(self.srcdir)
- utils.system(cmd)
+ # Make sure there is no ZFS in use by any filesystem
+ try:
+ utils.system('df -t zfs &> /dev/null') # return 1 if not found
+ print("ZFS in use by filesystem, SKIP cleanup")
+ except error.CmdError:
+ print("Stop / unload / remove ZFS")
+ utils.system('systemctl stop zed')
+ utils.system('modprobe -r zfs')
+ # No need to consider ubuntu-zfs package on P/T as they've been blacklisted
+ utils.system('apt-get remove --yes --force-yes zfsutils-linux')
+ # Remove .version for the test, in order to trigger setup() again if we want re-test it
+ cmd = 'rm {}/.version'.format(self.srcdir)
+ utils.system(cmd)
return
cmd = '%s/%s %s' % (self.bindir, test_name, self.srcdir)
@@ -78,13 +78,19 @@ class ubuntu_zfs(test.test):
if test_name == 'setup':
return
elif test_name == 'post-test-zfs-cleanup':
- utils.system('systemctl stop zed')
- utils.system('modprobe -r zfs')
- # No need to consider ubuntu-zfs package on P/T as they've been blacklisted
- utils.system('apt-get remove --yes --force-yes zfsutils-linux')
- # Remove .version for the test, in order to trigger setup() again if we want re-test it
- cmd = 'rm {}/.version'.format(self.srcdir)
- utils.system(cmd)
+ # Make sure there is no ZFS in use by any filesystem
+ try:
+ utils.system('df -t zfs &> /dev/null') # return 1 if not found
+ print("ZFS in use by filesystem, SKIP cleanup")
+ except error.CmdError:
+ print("Stop / unload / remove ZFS")
+ utils.system('systemctl stop zed')
+ utils.system('modprobe -r zfs')
+ # No need to consider ubuntu-zfs package on P/T as they've been blacklisted
+ utils.system('apt-get remove --yes --force-yes zfsutils-linux')
+ # Remove .version for the test, in order to trigger setup() again if we want re-test it
+ cmd = 'rm {}/.version'.format(self.srcdir)
+ utils.system(cmd)
return
os.chdir(self.srcdir)
@@ -4,6 +4,7 @@ import multiprocessing
import os
import platform
from autotest.client import test, utils
+from autotest.client.shared import error
class ubuntu_zfs_fstest(test.test):
version = 1
@@ -66,13 +67,19 @@ class ubuntu_zfs_fstest(test.test):
if test_name == 'setup':
return
elif test_name == 'post-test-zfs-cleanup':
- utils.system('systemctl stop zed')
- utils.system('modprobe -r zfs')
- # No need to consider ubuntu-zfs package on P/T as they've been blacklisted
- utils.system('apt-get remove --yes --force-yes zfsutils-linux')
- # Remove .version for the test, in order to trigger setup() again if we want re-test it
- cmd = 'rm {}/.version'.format(self.srcdir)
- utils.system(cmd)
+ # Make sure there is no ZFS in use by any filesystem
+ try:
+ utils.system('df -t zfs &> /dev/null') # return 1 if not found
+ print("ZFS in use by filesystem, SKIP cleanup")
+ except error.CmdError:
+ print("Stop / unload / remove ZFS")
+ utils.system('systemctl stop zed')
+ utils.system('modprobe -r zfs')
+ # No need to consider ubuntu-zfs package on P/T as they've been blacklisted
+ utils.system('apt-get remove --yes --force-yes zfsutils-linux')
+ # Remove .version for the test, in order to trigger setup() again if we want re-test it
+ cmd = 'rm {}/.version'.format(self.srcdir)
+ utils.system(cmd)
return
os.chdir(self.srcdir)
@@ -1,6 +1,7 @@
#
#
from autotest.client import test, utils
+from autotest.client.shared import error
import platform
class ubuntu_zfs_smoke_test(test.test):
@@ -39,13 +40,19 @@ class ubuntu_zfs_smoke_test(test.test):
if test_name == 'setup':
return
elif test_name == 'post-test-zfs-cleanup':
- utils.system('systemctl stop zed')
- utils.system('modprobe -r zfs')
- # No need to consider ubuntu-zfs package on P/T as they've been blacklisted
- utils.system('apt-get remove --yes --force-yes zfsutils-linux')
- # Remove .version for the test, in order to trigger setup() again if we want re-test it
- cmd = 'rm {}/.version'.format(self.srcdir)
- utils.system(cmd)
+ # Make sure there is no ZFS in use by any filesystem
+ try:
+ utils.system('df -t zfs &> /dev/null') # return 1 if not found
+ print("ZFS in use by filesystem, SKIP cleanup")
+ except error.CmdError:
+ print("Stop / unload / remove ZFS")
+ utils.system('systemctl stop zed')
+ utils.system('modprobe -r zfs')
+ # No need to consider ubuntu-zfs package on P/T as they've been blacklisted
+ utils.system('apt-get remove --yes --force-yes zfsutils-linux')
+ # Remove .version for the test, in order to trigger setup() again if we want re-test it
+ cmd = 'rm {}/.version'.format(self.srcdir)
+ utils.system(cmd)
return
cmd = '%s/%s %s' % (self.bindir, test_name, self.srcdir)
@@ -5,6 +5,7 @@ import os
import platform
import shutil
from autotest.client import test, utils
+from autotest.client.shared import error
class ubuntu_zfs_stress(test.test):
version = 1
@@ -64,13 +65,19 @@ class ubuntu_zfs_stress(test.test):
def run_once(self, test_name):
if test_name == 'post-test-zfs-cleanup':
- utils.system('systemctl stop zed')
- utils.system('modprobe -r zfs')
- # No need to consider ubuntu-zfs package on P/T as they've been blacklisted
- utils.system('apt-get remove --yes --force-yes zfsutils-linux')
- # Remove .version for the test, in order to trigger setup() again if we want re-test it
- cmd = 'rm {}/.version'.format(self.srcdir)
- utils.system(cmd)
+ # Make sure there is no ZFS in use by any filesystem
+ try:
+ utils.system('df -t zfs &> /dev/null') # return 1 if not found
+ print("ZFS in use by filesystem, SKIP cleanup")
+ except error.CmdError:
+ print("Stop / unload / remove ZFS")
+ utils.system('systemctl stop zed')
+ utils.system('modprobe -r zfs')
+ # No need to consider ubuntu-zfs package on P/T as they've been blacklisted
+ utils.system('apt-get remove --yes --force-yes zfsutils-linux')
+ # Remove .version for the test, in order to trigger setup() again if we want re-test it
+ cmd = 'rm {}/.version'.format(self.srcdir)
+ utils.system(cmd)
return
stress_ng = os.path.join(self.srcdir, 'stress-ng', 'stress-ng')
@@ -5,6 +5,7 @@ import platform
import shutil
from autotest.client import test, utils
from autotest.client import canonical
+from autotest.client.shared import error
class ubuntu_zfs_xfs_generic(test.test):
version = 5
@@ -133,13 +134,19 @@ class ubuntu_zfs_xfs_generic(test.test):
if test_name == 'setup':
return
elif test_name == 'post-test-zfs-cleanup':
- utils.system('systemctl stop zed')
- utils.system('modprobe -r zfs')
- # No need to consider ubuntu-zfs package on P/T as they've been blacklisted
- utils.system('apt-get remove --yes --force-yes zfsutils-linux')
- # Remove .version for the test, in order to trigger setup() again if we want re-test it
- cmd = 'rm {}/.version'.format(self.srcdir)
- utils.system(cmd)
+ # Make sure there is no ZFS in use by any filesystem
+ try:
+ utils.system('df -t zfs &> /dev/null') # return 1 if not found
+ print("ZFS in use by filesystem, SKIP cleanup")
+ except error.CmdError:
+ print("Stop / unload / remove ZFS")
+ utils.system('systemctl stop zed')
+ utils.system('modprobe -r zfs')
+ # No need to consider ubuntu-zfs package on P/T as they've been blacklisted
+ utils.system('apt-get remove --yes --force-yes zfsutils-linux')
+ # Remove .version for the test, in order to trigger setup() again if we want re-test it
+ cmd = 'rm {}/.version'.format(self.srcdir)
+ utils.system(cmd)
return
os.chdir(os.path.join(self.srcdir, 'xfstests-bld', 'xfstests-dev'))
BugLink: https://bugs.launchpad.net/bugs/1970600/ The post-test-zfs-cleanup add for zfs-related tests will break system that runs on ZFS. Check if the SUT is using it with "df -t zfs" before trying to do the cleanup. Patch tested on s390x LPAR with ubuntu_zfs_smoke_test test (not a zfs-based system though). Fixes: 4c9ac393e457 ("UBUNTU: SAUCE: Remove zfs-related packages after test") Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com> --- .../ubuntu_performance_fio.py | 22 ++++++++++++------- .../ubuntu_performance_zfs_encryption.py | 21 ++++++++++++------ ubuntu_zfs/ubuntu_zfs.py | 20 +++++++++++------ ubuntu_zfs_fstest/ubuntu_zfs_fstest.py | 21 ++++++++++++------ .../ubuntu_zfs_smoke_test.py | 21 ++++++++++++------ ubuntu_zfs_stress/ubuntu_zfs_stress.py | 21 ++++++++++++------ .../ubuntu_zfs_xfs_generic.py | 21 ++++++++++++------ 7 files changed, 97 insertions(+), 50 deletions(-)