[autotest-client-tests][PATCH] UBUNTU: SAUCE: Don't cleanup ZFS on system with ZFS filesystem in use
Po-Hsu Lin
po-hsu.lin at canonical.com
Thu Apr 28 04:57:59 UTC 2022
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 at 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(-)
diff --git a/ubuntu_performance_fio/ubuntu_performance_fio.py b/ubuntu_performance_fio/ubuntu_performance_fio.py
index 364f1b74..0efdcd4c 100644
--- a/ubuntu_performance_fio/ubuntu_performance_fio.py
+++ b/ubuntu_performance_fio/ubuntu_performance_fio.py
@@ -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
#
diff --git a/ubuntu_performance_zfs_encryption/ubuntu_performance_zfs_encryption.py b/ubuntu_performance_zfs_encryption/ubuntu_performance_zfs_encryption.py
index 912543f2..15e52a4d 100644
--- a/ubuntu_performance_zfs_encryption/ubuntu_performance_zfs_encryption.py
+++ b/ubuntu_performance_zfs_encryption/ubuntu_performance_zfs_encryption.py
@@ -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)
diff --git a/ubuntu_zfs/ubuntu_zfs.py b/ubuntu_zfs/ubuntu_zfs.py
index f91bf4e2..c1d53b42 100644
--- a/ubuntu_zfs/ubuntu_zfs.py
+++ b/ubuntu_zfs/ubuntu_zfs.py
@@ -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)
diff --git a/ubuntu_zfs_fstest/ubuntu_zfs_fstest.py b/ubuntu_zfs_fstest/ubuntu_zfs_fstest.py
index a557ed5b..8b793009 100644
--- a/ubuntu_zfs_fstest/ubuntu_zfs_fstest.py
+++ b/ubuntu_zfs_fstest/ubuntu_zfs_fstest.py
@@ -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)
diff --git a/ubuntu_zfs_smoke_test/ubuntu_zfs_smoke_test.py b/ubuntu_zfs_smoke_test/ubuntu_zfs_smoke_test.py
index 6ad6b4c7..41276eca 100644
--- a/ubuntu_zfs_smoke_test/ubuntu_zfs_smoke_test.py
+++ b/ubuntu_zfs_smoke_test/ubuntu_zfs_smoke_test.py
@@ -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)
diff --git a/ubuntu_zfs_stress/ubuntu_zfs_stress.py b/ubuntu_zfs_stress/ubuntu_zfs_stress.py
index e2e68799..6103a27b 100644
--- a/ubuntu_zfs_stress/ubuntu_zfs_stress.py
+++ b/ubuntu_zfs_stress/ubuntu_zfs_stress.py
@@ -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')
diff --git a/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py b/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py
index 11bae635..8fff91a3 100644
--- a/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py
+++ b/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py
@@ -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'))
--
2.25.1
More information about the kernel-team
mailing list