[autotest-client-tests][PATCH 1/1] UBUNTU: SAUCE: Remove zfs-related packages after test

Po-Hsu Lin po-hsu.lin at canonical.com
Wed Apr 20 12:39:21 UTC 2022


BugLink: https://bugs.launchpad.net/bugs/1892124

Stop zfs daemon and remove zfs related packages after test to prevent
manually provisioned system from booting with out-of-tree zfs modules
and failed with the kernel_tainted test in ubuntu_boot like:
    Kernel taint value is 4097
    Taint bit value: 0 (proprietary module was loaded)
    *   Modules with GPL Incompatible Licenses:
         zfs: CDDL
         zunicode: CDDL
         zcommon: CDDL
         znvpair: CDDL
         zavl: CDDL
         icp: CDDL
    Taint bit value: 12 (externally-built ('out-of-tree') module was loaded)
    *   Modules not in-tree:
         zfs
         zunicode
         zzstd
         zlua
         zcommon
         znvpair
         zavl
         icp
         spl

This is done by adding a sub-test called post-test-zfs-cleanup and
catch it in run_once(). Not using cleanup() because it will be
triggered after each sub test. It's fine for test like
ubuntu_zfs_stress, but it will be complicated for test with multiple
sub-tests e.g. ubuntu_zfs_xfs_generic

The downside of this is that if you're trying to run it again on
the same SUT manully without removing the autotest/client/tmp/
directory, the setup task won't be triggered as the test version
didn't change. To workaround this we will need to move the code in
setup() to initialize() like what we did for ubuntu_sysdig_smoke_test,
to trigger the package installation, or, remove the .version file in
autotest/client/tmp/TESTNAME/

Search criteria to locate tests that need this change:
    grep -r zfsutils-linux *

Signed-off-by: Po-Hsu Lin <po-hsu.lin at canonical.com>
---
 ubuntu_performance_fio/control                       |  1 +
 ubuntu_performance_fio/ubuntu_performance_fio.py     |  9 +++++++++
 ubuntu_performance_zfs_encryption/control            |  1 +
 .../ubuntu_performance_zfs_encryption.py             | 10 ++++++++++
 ubuntu_zfs/control                                   |  6 ++++--
 ubuntu_zfs/ubuntu_zfs.py                             |  9 +++++++++
 ubuntu_zfs_fstest/control                            |  5 +++--
 ubuntu_zfs_fstest/ubuntu_zfs_fstest.py               | 11 ++++++++++-
 ubuntu_zfs_smoke_test/control                        |  1 +
 ubuntu_zfs_smoke_test/ubuntu_zfs_smoke_test.py       | 10 ++++++++++
 ubuntu_zfs_stress/control                            |  5 ++---
 ubuntu_zfs_stress/ubuntu_zfs_stress.py               | 10 ++++++++++
 ubuntu_zfs_xfs_generic/control                       |  3 ++-
 ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py     | 12 +++++++++++-
 14 files changed, 83 insertions(+), 10 deletions(-)

diff --git a/ubuntu_performance_fio/control b/ubuntu_performance_fio/control
index f43edc6c..557c7b76 100644
--- a/ubuntu_performance_fio/control
+++ b/ubuntu_performance_fio/control
@@ -27,6 +27,7 @@ tests = [
 
     'rd-75,wr-25,rand,blk-128k,jobs-16',
     'rd-75,wr-25,rand,blk-8k,jobs-64',
+    'post-test-zfs-cleanup',
 ]
 
 results = job.run_test_detail('ubuntu_performance_fio', test_name='setup', tag='setup', media='', timeout=60*30)
diff --git a/ubuntu_performance_fio/ubuntu_performance_fio.py b/ubuntu_performance_fio/ubuntu_performance_fio.py
index c1affc7f..364f1b74 100644
--- a/ubuntu_performance_fio/ubuntu_performance_fio.py
+++ b/ubuntu_performance_fio/ubuntu_performance_fio.py
@@ -408,6 +408,15 @@ class ubuntu_performance_fio(test.test):
             self.setup()
             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)
+            return
 
         #
         #  Drop cache to get a good idea of how much free memory can be used
diff --git a/ubuntu_performance_zfs_encryption/control b/ubuntu_performance_zfs_encryption/control
index aa9eaecb..b0d4bf95 100644
--- a/ubuntu_performance_zfs_encryption/control
+++ b/ubuntu_performance_zfs_encryption/control
@@ -13,6 +13,7 @@ DOC = ""
 tests = [
     'setup',
     'performance-test-encryption',
+    'post-test-zfs-cleanup',
     ]
 
 import os
diff --git a/ubuntu_performance_zfs_encryption/ubuntu_performance_zfs_encryption.py b/ubuntu_performance_zfs_encryption/ubuntu_performance_zfs_encryption.py
index ed09eb10..912543f2 100644
--- a/ubuntu_performance_zfs_encryption/ubuntu_performance_zfs_encryption.py
+++ b/ubuntu_performance_zfs_encryption/ubuntu_performance_zfs_encryption.py
@@ -38,6 +38,16 @@ class ubuntu_performance_zfs_encryption(test.test):
     def run_once(self, test_name):
         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)
+            return
+
         cmd = '%s/%s %s' % (self.bindir, test_name, self.srcdir)
         self.results = utils.system_output(cmd, retain_output=True)
         print(self.results)
diff --git a/ubuntu_zfs/control b/ubuntu_zfs/control
index 32ae4d34..69729c2c 100644
--- a/ubuntu_zfs/control
+++ b/ubuntu_zfs/control
@@ -12,7 +12,7 @@ DOC = ""
 
 # This forces setup() to be run, it is in fact a no-op test
 #
-results = job.run_test_detail('ubuntu_zfs', test_name='setup', timeout=60*20)
+results = job.run_test_detail(NAME, test_name='setup', timeout=60*20)
 
 import os
 srcdir = os.path.join(job.bindir, 'tmp', NAME, 'src')
@@ -22,7 +22,9 @@ for fid in os.listdir(os.path.join(srcdir, 'tests')):
             for line in fin:
                 fout.write(line.replace('PATHNAME', os.path.join(srcdir, 'test/zfs-tests')))
 
-    results = job.run_test_detail('ubuntu_zfs', test_name='zfs-tests', tag='zfs-tests.%s' % os.path.split(fid)[-1].split('-', 1)[1], timeout=60*60*3)
+    results = job.run_test_detail(NAME, test_name='zfs-tests', tag='zfs-tests.%s' % os.path.split(fid)[-1].split('-', 1)[1], timeout=60*60*3)
+
+job.run_test_detail(NAME, test_name='post-test-zfs-cleanup', tag='post-test-zfs-cleanup', timeout=60*10)
 
 
 # vi:set ts=4 sw=4 expandtab syntax=python:
diff --git a/ubuntu_zfs/ubuntu_zfs.py b/ubuntu_zfs/ubuntu_zfs.py
index 5e7bef03..f91bf4e2 100644
--- a/ubuntu_zfs/ubuntu_zfs.py
+++ b/ubuntu_zfs/ubuntu_zfs.py
@@ -77,6 +77,15 @@ class ubuntu_zfs(test.test):
     def run_once(self, test_name):
         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)
+            return
 
         os.chdir(self.srcdir)
         cmd = 'RUNFILE="-c %s/linux.run" make test' % self.srcdir
diff --git a/ubuntu_zfs_fstest/control b/ubuntu_zfs_fstest/control
index e897830b..bfb27d81 100644
--- a/ubuntu_zfs_fstest/control
+++ b/ubuntu_zfs_fstest/control
@@ -10,9 +10,10 @@ TEST_CATEGORY = 'Functional'
 TEST_TYPE = "client"
 DOC = ""
 
-results = job.run_test_detail('ubuntu_zfs_fstest', test_name='setup', tag='setup', timeout=30*60)
+results = job.run_test_detail(NAME, test_name='setup', tag='setup', timeout=30*60)
 print("Invoking zfs fstest functional tests..")
-results = job.run_test_detail('ubuntu_zfs_fstest', test_name='zfs-tests', tag='zfs-tests', timeout=10*60)
+results = job.run_test_detail(NAME, test_name='zfs-tests', tag='zfs-tests', timeout=10*60)
+job.run_test_detail(NAME, test_name='post-test-zfs-cleanup', tag='post-test-zfs-cleanup', timeout=10*60)
 
 print("Done!")
 
diff --git a/ubuntu_zfs_fstest/ubuntu_zfs_fstest.py b/ubuntu_zfs_fstest/ubuntu_zfs_fstest.py
index 434272fd..a557ed5b 100644
--- a/ubuntu_zfs_fstest/ubuntu_zfs_fstest.py
+++ b/ubuntu_zfs_fstest/ubuntu_zfs_fstest.py
@@ -64,7 +64,16 @@ class ubuntu_zfs_fstest(test.test):
         #  invoked, then we can run run_once per test
         #
         if test_name == 'setup':
-                return
+            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)
+            return
 
         os.chdir(self.srcdir)
         tmp_pool = os.path.join(self.srcdir, 'pool.img')
diff --git a/ubuntu_zfs_smoke_test/control b/ubuntu_zfs_smoke_test/control
index 5fabc334..30a9d158 100644
--- a/ubuntu_zfs_smoke_test/control
+++ b/ubuntu_zfs_smoke_test/control
@@ -26,6 +26,7 @@ tests = [
     'kernel-smoke-test-send-receive',
     'kernel-smoke-test-scrub',
     'kernel-smoke-test-encrypt',
+    'post-test-zfs-cleanup',
     ]
 
 import os
diff --git a/ubuntu_zfs_smoke_test/ubuntu_zfs_smoke_test.py b/ubuntu_zfs_smoke_test/ubuntu_zfs_smoke_test.py
index 73d15cdc..6ad6b4c7 100644
--- a/ubuntu_zfs_smoke_test/ubuntu_zfs_smoke_test.py
+++ b/ubuntu_zfs_smoke_test/ubuntu_zfs_smoke_test.py
@@ -38,6 +38,16 @@ class ubuntu_zfs_smoke_test(test.test):
     def run_once(self, test_name):
         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)
+            return
+
         cmd = '%s/%s %s' % (self.bindir, test_name, self.srcdir)
         self.results = utils.system_output(cmd, retain_output=True)
 
diff --git a/ubuntu_zfs_stress/control b/ubuntu_zfs_stress/control
index 567d842f..2bc02210 100644
--- a/ubuntu_zfs_stress/control
+++ b/ubuntu_zfs_stress/control
@@ -12,11 +12,10 @@ TEST_CATEGORY = 'Functional'
 TEST_TYPE = "client"
 DOC = ""
 
-name = 'ubuntu_zfs_stress'
-
 if platform.machine() in ['riscv64', 'riscv']:
     print("Test skipped as it takes too long to run on this platform\n")
 else:
-    results = job.run_test_detail('ubuntu_zfs_stress', test_name='zfs-stress', tag='zfs-stress', timeout=60*60*5) # 5hr. timeout
+    results = job.run_test_detail(NAME, test_name='zfs-stress', tag='zfs-stress', timeout=60*60*5) # 5hr. timeout
+    job.run_test_detail(NAME, test_name='post-test-zfs-cleanup', tag='post-test-zfs-cleanup', timeout=60*10)
 
 # vi:set ts=4 sw=4 expandtab syntax=python:
diff --git a/ubuntu_zfs_stress/ubuntu_zfs_stress.py b/ubuntu_zfs_stress/ubuntu_zfs_stress.py
index db49ee65..e2e68799 100644
--- a/ubuntu_zfs_stress/ubuntu_zfs_stress.py
+++ b/ubuntu_zfs_stress/ubuntu_zfs_stress.py
@@ -63,6 +63,16 @@ class ubuntu_zfs_stress(test.test):
         utils.system('modprobe zfs')
 
     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)
+            return
+
         stress_ng = os.path.join(self.srcdir, 'stress-ng', 'stress-ng')
         #
         #  temp logfile
diff --git a/ubuntu_zfs_xfs_generic/control b/ubuntu_zfs_xfs_generic/control
index 03d1babf..591d6b8d 100644
--- a/ubuntu_zfs_xfs_generic/control
+++ b/ubuntu_zfs_xfs_generic/control
@@ -32,7 +32,8 @@ else:
             '184', '169', '192', '215', '221', '236',
             '237', '241', '245', '246', '247', '248', '249',
             '257', '258', '285', '294', '306', '307',
-            '308', '309', '310', '313'
+            '308', '309', '310', '313',
+            'post-test-zfs-cleanup'
         ]
 
         #
diff --git a/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py b/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py
index f5ede8b8..11bae635 100644
--- a/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py
+++ b/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py
@@ -131,7 +131,17 @@ class ubuntu_zfs_xfs_generic(test.test):
         #  invoked, then we can run run_once per test
         #
         if test_name == 'setup':
-                return
+            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)
+            return
+
         os.chdir(os.path.join(self.srcdir, 'xfstests-bld', 'xfstests-dev'))
         cmd = '%s/ubuntu_zfs_xfs_generic.sh %s %s' % (self.bindir, test_name, self.srcdir)
         print("Running: " + cmd)
-- 
2.25.1




More information about the kernel-team mailing list