summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLee Duncan <lduncan@suse.com>2020-02-20 13:56:57 -0800
committerLee Duncan <lduncan@suse.com>2020-02-20 13:56:57 -0800
commit874767df96db070d59c4151ab5a44bd9a23d75b0 (patch)
treea4955289a417aaa3a495160f28759e13c0ff01a8 /test
parent8248e122bd184f23860bc2575bd650e6b8d0a468 (diff)
downloadopen-iscsi-874767df96db070d59c4151ab5a44bd9a23d75b0.tar.gz
Allow sub-tests to be specified.
Using the new "-s" option, one can specify a single subtest or a range of subtests. Together with the blocksize arguments and being able to specify the actual test case if you wish, you can now run just a single test.
Diffstat (limited to 'test')
-rw-r--r--test/harness/tests.py80
-rw-r--r--test/harness/util.py62
2 files changed, 121 insertions, 21 deletions
diff --git a/test/harness/tests.py b/test/harness/tests.py
index 7cc960b..7833aac 100644
--- a/test/harness/tests.py
+++ b/test/harness/tests.py
@@ -58,11 +58,14 @@ class TestRegression(unittest.TestCase):
i = 1
for v in self.param_values:
with self.subTest('Testing FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v), i=i):
- util.vprint('Running subtest %d: FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v) % i)
- self.iscsi_logout()
- iscsi_data = IscsiData('No', 'Yes', 'None', 'None', v[0], v[1], v[2])
- iscsi_data.update_cfg(Global.target, Global.ipnr)
- self.run_the_rest()
+ if i not in Global.subtest_list:
+ util.vprint('Skipping subtest %d: FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v) % i)
+ else:
+ util.vprint('Running subtest %d: FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v) % i)
+ self.iscsi_logout()
+ iscsi_data = IscsiData('No', 'Yes', 'None', 'None', v[0], v[1], v[2])
+ iscsi_data.update_cfg(Global.target, Global.ipnr)
+ self.run_the_rest()
i += 1
def test_InitialR2T_off_ImmediateData_on(self):
@@ -70,10 +73,13 @@ class TestRegression(unittest.TestCase):
i = 1
for v in self.param_values:
with self.subTest('Testing FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v), i=i):
- self.iscsi_logout()
- iscsi_data = IscsiData('Yes', 'No', 'None', 'None', v[0], v[1], v[2])
- iscsi_data.update_cfg(Global.target, Global.ipnr)
- self.run_the_rest()
+ if i not in Global.subtest_list:
+ util.vprint('Skipping subtest %d: FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v) % i)
+ else:
+ self.iscsi_logout()
+ iscsi_data = IscsiData('Yes', 'No', 'None', 'None', v[0], v[1], v[2])
+ iscsi_data.update_cfg(Global.target, Global.ipnr)
+ self.run_the_rest()
i += 1
def test_InitialR2T_on_ImmediateData_on(self):
@@ -81,11 +87,14 @@ class TestRegression(unittest.TestCase):
i = 1
for v in self.param_values:
with self.subTest('Testing FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v), i=i):
- util.vprint('Running subtest %d: FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v) % i)
- self.iscsi_logout()
- iscsi_data = IscsiData('Yes', 'Yes', 'None', 'None', v[0], v[1], v[2])
- iscsi_data.update_cfg(Global.target, Global.ipnr)
- self.run_the_rest()
+ if i not in Global.subtest_list:
+ util.vprint('Skipping subtest %d: FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v) % i)
+ else:
+ util.vprint('Running subtest %d: FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v) % i)
+ self.iscsi_logout()
+ iscsi_data = IscsiData('Yes', 'Yes', 'None', 'None', v[0], v[1], v[2])
+ iscsi_data.update_cfg(Global.target, Global.ipnr)
+ self.run_the_rest()
i += 1
def test_InitialR2T_off_ImmediateData_off(self):
@@ -93,11 +102,44 @@ class TestRegression(unittest.TestCase):
i = 1
for v in self.param_values:
with self.subTest('Testing FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v), i=i):
- util.vprint('Running subtest %d: FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v) % i)
- self.iscsi_logout()
- iscsi_data = IscsiData('No', 'No', 'None', 'None', v[0], v[1], v[2])
- iscsi_data.update_cfg(Global.target, Global.ipnr)
- self.run_the_rest()
+ if i not in Global.subtest_list:
+ util.vprint('Skipping subtest %d: FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v) % i)
+ else:
+ util.vprint('Running subtest %d: FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v) % i)
+ self.iscsi_logout()
+ iscsi_data = IscsiData('No', 'No', 'None', 'None', v[0], v[1], v[2])
+ iscsi_data.update_cfg(Global.target, Global.ipnr)
+ self.run_the_rest()
+ i += 1
+
+ def test_HdrDigest_on_DataDigest_off(self):
+ """Test With Header Digest"""
+ i = 1
+ for v in self.param_values:
+ with self.subTest('Testing FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v), i=i):
+ if i not in Global.subtest_list:
+ util.vprint('Skipping subtest %d: FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v) % i)
+ else:
+ util.vprint('Running subtest %d: FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v) % i)
+ self.iscsi_logout()
+ iscsi_data = IscsiData('No', 'Yes', 'CRC32C', 'None', v[0], v[1], v[2])
+ iscsi_data.update_cfg(Global.target, Global.ipnr)
+ self.run_the_rest()
+ i += 1
+
+ def test_HdrDigest_on_DataDigest_on(self):
+ """Test With Header Digest"""
+ i = 1
+ for v in self.param_values:
+ with self.subTest('Testing FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v), i=i):
+ if i not in Global.subtest_list:
+ util.vprint('Skipping subtest %d: FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v) % i)
+ else:
+ util.vprint('Running subtest %d: FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v) % i)
+ self.iscsi_logout()
+ iscsi_data = IscsiData('No', 'Yes', 'CRC32C', 'CRC32C', v[0], v[1], v[2])
+ iscsi_data.update_cfg(Global.target, Global.ipnr)
+ self.run_the_rest()
i += 1
def run_the_rest(self):
diff --git a/test/harness/util.py b/test/harness/util.py
index ff0fc13..f6c2a32 100644
--- a/test/harness/util.py
+++ b/test/harness/util.py
@@ -8,6 +8,7 @@ import sys
import unittest
import time
import tempfile
+import re
from . import __version__ as lib_version
@@ -37,6 +38,10 @@ class Global:
partition = None
# optional override for fio disk testing block size(s)
blocksize = None
+ # subtests to run -- by default, all of them
+ # XXX we should really look how many subtests there are, but there's
+ # no good way to detect that.
+ subtest_list = [i+1 for i in range(16)]
def dprint(*args):
@@ -121,6 +126,9 @@ def new_initArgParsers(self):
self._main_parser.add_argument('-l', '--list', dest='list_tests',
action='store_true',
help='List test cases and exit')
+ self._main_parser.add_argument('-s', '--subtests', dest='subtest_list',
+ action='store',
+ help='Subtests to execute [default all, i.e. "1-16"]')
def print_suite(suite):
"""Print a list of tests from a test suite"""
@@ -139,7 +147,10 @@ def new_parseArgs(self, argv):
"""
global old_parseArgs, prog_name, parent_version, lib_version
+ # actually parse the arguments
old_parseArgs(self, argv)
+
+ # now validate stuff
if self.version_request:
print('%s Version %s, harnes version %s' % \
(prog_name, parent_version, lib_version))
@@ -167,7 +178,49 @@ def new_parseArgs(self, argv):
print('Error: must start with "/dev" or "/dev/disk/by-{id,path}": %s' % \
Global.device, file=sys.sttderr)
sys.exit(1)
+ if self.subtest_list:
+ if not user_spec_to_list(self.subtest_list):
+ self._print_help()
+ sys.exit(1)
+
+def user_spec_to_list(user_spec):
+ """
+ We have 16 subtests. By default, we run them all, but if
+ the user has specified a subset, like 'N' or 'N-M', then
+ a list of the indicies they requested.
+
+ XXX: expand to handle groups, e.g. 1,3-4,12 ???
+ XXX: should we validate that the range will work, or just
+ let an exception happen in that case?
+ """
+ pat_single = re.compile(r'(\d+)$')
+ pat_range = re.compile(r'(\d+)-(\d+)$')
+ found = False
+ start_idx = None
+ end_idx = None
+ res = pat_range.match(user_spec)
+ if res:
+ # user wants just one subtest
+ start_idx = int(res.group(1)) - 1
+ end_idx = int(res.group(2))
+ dprint("Found request for range: %d-%d" % (start_idx, end_idx))
+ found = True
+ else:
+ res = pat_single.match(user_spec)
+ if res:
+ start_idx = int(res.group(1)) - 1
+ end_idx = start_idx + 1
+ dprint("Found request for single: %d-%d" % (start_idx, end_idx))
+ found = True
+ if not found:
+ print('Error: subtest spec does not match N or N-M: %s' % user_spec)
+ else:
+ dprint("subtest_list before:", Global.subtest_list)
+ Global.subtest_list = Global.subtest_list[start_idx:end_idx]
+ dprint("subtest_list after:", Global.subtest_list)
+ return found
+
def setup_testProgram_overrides(version_str, name):
"""
Add in special handling for a couple of the methods in TestProgram (main)
@@ -264,11 +317,14 @@ def wipe_disc():
table has been erased
"""
# zero out the label and parition table
- vprint('Running "sgdisk" to wipe disc label and partitions')
+ vprint('Running "sgdisk" and "dd" to wipe disc label, partitions, and filesystem')
time.sleep(1)
res = run_cmd(['sgdisk', '-Z', Global.device])
if res != 0:
return (res, '%s: could not zero out label: %d' % (Global.device, res))
+ res = run_cmd(['dd', 'if=/dev/zero', 'of=%s' % Global.device, 'bs=256k', 'count=20', 'oflag=direct'])
+ if res != 0:
+ return (res, '%s: could not zero out filesystem: %d' % (Global.device, res))
return (0, 'Success')
def run_parted():
@@ -281,7 +337,9 @@ def run_parted():
Uses Globals: device, partition
"""
- wipe_disc()
+ (res, reason) = wipe_disc()
+ if res != 0:
+ return (res, resason)
# ensure our partition file is not there, to be safe
if not wait_for_path(Global.partition, present=False, amt=30):
return (1, '%s: Partition already exists?' % Global.partition)