summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLee Duncan <lduncan@suse.com>2020-02-20 10:17:37 -0800
committerLee Duncan <lduncan@suse.com>2020-02-20 10:17:37 -0800
commitdcf514967a8b530c71f2b5531936b9953df25960 (patch)
tree75bdd250d5671a95a93f0d2f6c3a6e0e11c5ed75 /test
parent8293415f4b0e32348d4ba183b5877d304efc0632 (diff)
downloadopen-iscsi-dcf514967a8b530c71f2b5531936b9953df25960.tar.gz
64 tests now working and passing
Tested on Tumbleweed, and all tests pass so far. Run time is around 3 hours so far, for the whole suite.
Diffstat (limited to 'test')
-rw-r--r--test/TODO14
-rw-r--r--test/harness/util.py44
-rwxr-xr-xtest/test-open-iscsi.py35
3 files changed, 68 insertions, 25 deletions
diff --git a/test/TODO b/test/TODO
index 830e7f2..1ab7048 100644
--- a/test/TODO
+++ b/test/TODO
@@ -2,13 +2,14 @@
* this will mean replacing disktest with something
(like fio?)
-* convert to PyTest insteal of shell
+* ensure user is root?
* have tests create their own target using targetcli and
a file?
* have tests do discovery themselves, instead of requiring
- that to be done already
+ that to be done already. Either way, we may still need
+ to know the IQN of our target and the host where it lives.
* Augment tests
* framework for adding new tests and test types,e.g.:
@@ -21,4 +22,11 @@
* Gather actual regression data!
- Since we are testing all of these combinations, why not
keep historical data to see if there are any negative
- trends (i.e. regressions)?
+ trends (i.e. regressions)? Need to understand fio and bonnie++
+ output better to find a way to gather one or two datapoints
+ (max) per test, out of all the info dumped by these
+ programs.
+
+* Add in test cases for Discovery and/or Connection validation,
+ which would require either a separate target set up for that,
+ or control of our own target
diff --git a/test/harness/util.py b/test/harness/util.py
index 8c310ed..35f56cb 100644
--- a/test/harness/util.py
+++ b/test/harness/util.py
@@ -116,7 +116,9 @@ def new_initArgParsers(self):
def new_parseArgs(self, argv):
"""
- Gather globals from unittest main for local consumption
+ Gather globals from unittest main for local consumption -- this
+ called to parse then validate the arguments, inside each TestCase
+ instance.
"""
global old_parseArgs
@@ -218,21 +220,32 @@ def run_fio():
return (res, 'fio failed')
return (0, 'Success')
-def wait_for_path(path, present=True):
+def wait_for_path(path, present=True, amt=10):
"""Wait until a path exists or is gone"""
dprint("Looking for path=%s, present=%s" % (path, present))
- for i in range(10):
- if os.path.exists(path) == present:
- dprint("Found path!")
- break
+ for i in range(amt):
time.sleep(1)
- if os.path.exists(path) != present:
- dprint("Did NOT find path!")
- return False
- dprint("%s: present=%d after %d second(s)" % \
- (path, present, i))
- return True
+ if os.path.exists(path) == present:
+ dprint("We are Happy :) present=%s, cnt=%d" % (present, i))
+ return True
+ dprint("We are not happy :( present=%s actual=%s after %d seconds" % \
+ (present, os.path.exists(path), amt))
+ return False
+def wipe_disc():
+ """
+ Wipe the label and partition table from the disc drive -- the sleep-s
+ are needed to give the async OS and udev a chance to notice the partition
+ table has been erased
+ """
+ # zero out the label and parition table
+ vprint('Running "sgdisk" to wipe disc label and partitions')
+ 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))
+ return (0, 'Success')
+
def run_parted():
"""
Run the parted program to ensure there is one partition,
@@ -243,12 +256,9 @@ def run_parted():
Uses Globals: device, partition
"""
- # zero out the label and parition table
- res = run_cmd(['dd', 'if=/dev/zero', 'of=%s' % Global.device, 'bs=4k', 'count=100'])
- if res != 0:
- return (res, '%s: could not zero out label' % Global.device)
+ wipe_disc()
# ensure our partition file is not there, to be safe
- if not wait_for_path(Global.partition, present=False):
+ if not wait_for_path(Global.partition, present=False, amt=30):
return (1, '%s: Partition already exists?' % Global.partition)
# make a label, then a partition table with one partition
vprint('Running "parted" to create a label and partition table')
diff --git a/test/test-open-iscsi.py b/test/test-open-iscsi.py
index 7c06c59..9967e21 100755
--- a/test/test-open-iscsi.py
+++ b/test/test-open-iscsi.py
@@ -19,7 +19,7 @@ class TestRegression(unittest.TestCase):
@classmethod
def setUpClass(cls):
- util.verify_needed_commands_exist(['parted', 'fio', 'mkfs', 'bonnie++', 'dd', 'iscsiadm'])
+ util.verify_needed_commands_exist(['parted', 'fio', 'mkfs', 'bonnie++', 'sgdisk', 'iscsiadm'])
util.vprint('*** Starting %s' % cls.__name__)
# XXX validate that target exists?
# an array of first burts, max burst, and max recv values, for testing
@@ -54,19 +54,20 @@ class TestRegression(unittest.TestCase):
self.fail('logout failed')
self.assertFalse(os.path.exists(Global.device), '%s: exists after logout!' % Global.device)
- def test_InitialR2T(self):
- """Test Initial Request to Transmit set, but no Immediate Data"""
+ def test_InitialR2T_on(self):
+ """Test Initial Request to Transmit on, but Immediate Data off"""
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()
i += 1
- def test_ImmediateData(self):
- """Test Initial Request to Transmit set, but no Immediate Data"""
+ def test_ImmediateData_on(self):
+ """Test Initial Request to Transmit off, Immediate Data on"""
i = 1
for v in self.param_values:
with self.subTest('Testing FirstBurst={} MaxBurts={} MaxRecv={}'.format(*v), i=i):
@@ -76,6 +77,30 @@ class TestRegression(unittest.TestCase):
self.run_the_rest()
i += 1
+ def test_InitialR2T_and_ImmediateData_on(self):
+ """Test Initial Request to Transmit and Immediate Data on"""
+ 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()
+ i += 1
+
+ def test_InitialR2T_and_ImmediateData_off(self):
+ """Test Initial Request to Transmit and Immediate Data off"""
+ 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()
+ i += 1
+
def run_the_rest(self):
res = util.run_cmd(['iscsiadm', '-m', 'node',
'-T', Global.target,