diff options
author | Lee Duncan <lduncan@suse.com> | 2020-02-19 15:39:13 -0800 |
---|---|---|
committer | Lee Duncan <lduncan@suse.com> | 2020-02-19 15:39:13 -0800 |
commit | 8293415f4b0e32348d4ba183b5877d304efc0632 (patch) | |
tree | 2ae0b58476ba5455115bb00eaf5c39e60e20f118 /test/test-open-iscsi.py | |
parent | f66c504430a6c568bf90a5cdf2a64eb995b557de (diff) | |
download | open-iscsi-8293415f4b0e32348d4ba183b5877d304efc0632.tar.gz |
First 32 tests working?
At least they are coded.
Diffstat (limited to 'test/test-open-iscsi.py')
-rwxr-xr-x | test/test-open-iscsi.py | 76 |
1 files changed, 58 insertions, 18 deletions
diff --git a/test/test-open-iscsi.py b/test/test-open-iscsi.py index 8d5bdeb..7c06c59 100755 --- a/test/test-open-iscsi.py +++ b/test/test-open-iscsi.py @@ -6,6 +6,7 @@ Unit tests for open-iscsi, using the unittest built-in package import sys import unittest import os +import time from harness import util from harness.util import Global from harness.iscsi import IscsiData @@ -18,35 +19,72 @@ class TestRegression(unittest.TestCase): @classmethod def setUpClass(cls): + util.verify_needed_commands_exist(['parted', 'fio', 'mkfs', 'bonnie++', 'dd', 'iscsiadm']) util.vprint('*** Starting %s' % cls.__name__) # XXX validate that target exists? - cls.first_burst_values = [4096, 8192, 16384, 32768, 65536, 131972] - cls.max_burst_values = [4096, 8192, 16384, 32768, 65536, 131072] - cls.max_recv_values = [4096, 8192, 16384, 32768, 65536, 131072] + # an array of first burts, max burst, and max recv values, for testing + cls.param_values = [[4096, 4096, 4096], + [8192, 4096, 4096], + [16384, 4096, 4096], + [32768, 4096, 4096], + [65536, 4096, 4096], + [131972, 4096, 4096], + [4096, 8192, 4096], + [4096, 16384, 4096], + [4096, 32768, 4096], + [4096, 65536, 4096], + [4096, 131072, 4096], + [4096, 4096, 8192], + [4096, 4096, 16384], + [4096, 4096, 32768], + [4096, 4096, 65536], + [4096, 4096, 131072]] def setUp(self): if Global.debug or Global.verbosity > 1: # this makes debug printing a little more clean print('', file=sys.stderr) - res = util.run_cmd(['iscsiadm', '-m', 'node', '-T', Global.target, '-p', Global.ipnr, '--logout'], quiet_mode=True) + + def iscsi_logout(self): + res = util.run_cmd(['iscsiadm', '-m', 'node', + '-T', Global.target, + '-p', Global.ipnr, + '--logout']) if res not in [0, 21]: self.fail('logout failed') self.assertFalse(os.path.exists(Global.device), '%s: exists after logout!' % Global.device) - def test_immediate_data(self): - """ - Test No Immediate Data but Initial Request to Transmit - """ - iscsi_data = IscsiData('No', 'Yes', 'None', 'None', 4096, 4096, 4096) - iscsi_data.update_cfg(Global.target, Global.ipnr) - res = util.run_cmd(['iscsiadm', '-m', 'node', '-T', Global.target, '-p', Global.ipnr, '--login'], quiet_mode=True) + def test_InitialR2T(self): + """Test Initial Request to Transmit set, but no Immediate Data""" + 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('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""" + 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() + i += 1 + + def run_the_rest(self): + res = util.run_cmd(['iscsiadm', '-m', 'node', + '-T', Global.target, + '-p', Global.ipnr, + '--login']) self.assertEqual(res, 0, 'cannot login to device') # wait a few seconds for the device to show up - for i in range(10): - if os.path.exists(Global.device): - break - os.sleep(1) - self.assertTrue(os.path.exists(Global.device), '%s: does not exist after login' % Global.device) + if not util.wait_for_path(Global.device): + self.fail('%s: does not exist after login' % Global.device) (res, reason) = util.run_fio() self.assertEqual(res, 0, reason) (res, reason) = util.run_parted() @@ -62,11 +100,13 @@ class TestRegression(unittest.TestCase): iscsi_data = IscsiData() iscsi_data.update_cfg(Global.target, Global.ipnr) # log out of iscsi connection - util.run_cmd(['iscsiadm', '-m', 'node', '-T', Global.target, '-p', Global.ipnr, '--logout'], quiet_mode=True) + util.run_cmd(['iscsiadm', '-m', 'node', + '-T', Global.target, + '-p', Global.ipnr, + '--logout']) if __name__ == '__main__': - util.verify_needed_commands_exist(['parted', 'fio', 'mkfs', 'bonnie++', 'dd', 'iscsiadm']) # do our own hackery first, to get access to verbosity, debug, etc, # as well as add our own command-line options util.setup_testProgram_overrides() |