summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLee Duncan <lduncan@suse.com>2022-03-01 08:50:31 -0800
committerLee Duncan <lduncan@suse.com>2022-03-01 10:53:39 -0800
commit16d4ab005ad55242b19cd1ebef92f82a61ad27db (patch)
treee8a96ab9d8e5f312f872b0ae6de163cbec30b64d /test
parent39c3dcc64727610b3ef1b8fa216b4444ceb20850 (diff)
downloadopen-iscsi-16d4ab005ad55242b19cd1ebef92f82a61ad27db.tar.gz
test: Track time spent in sleep() more easily/accurately
Diffstat (limited to 'test')
-rw-r--r--test/harness/tests.py4
-rw-r--r--test/harness/util.py15
2 files changed, 13 insertions, 6 deletions
diff --git a/test/harness/tests.py b/test/harness/tests.py
index f5068bb..224f216 100644
--- a/test/harness/tests.py
+++ b/test/harness/tests.py
@@ -158,6 +158,8 @@ class TestRegression(unittest.TestCase):
# run fio to test file IO
(res, reason) = util.run_fio()
self.assertEqual(res, 0, reason)
+ # wait a bit for cache to flush
+ util.sleep_some(1)
# make a filesystem
(res, reason) = util.run_mkfs()
self.assertEqual(res, 0, reason)
@@ -175,7 +177,7 @@ class TestRegression(unittest.TestCase):
'-T', Global.target,
'-p', Global.ipnr,
'--logout'])
- util.vprint("Times: fio=%-5.3f, sgdisk=%-5.3f, dd=%-5.3f, bonnie=%-5.3f, mkfs=%-5.3f, sleep=%d" % \
+ util.vprint("Times: fio=%-.3f, sgdisk=%-.3f, dd=%-.3f, bonnie=%-.3f, mkfs=%-.3f, sleep=%-.3f" % \
(Global.fio_time, Global.sgdisk_time, Global.dd_time, \
Global.bonnie_time, Global.mkfs_time, Global.sleep_time))
diff --git a/test/harness/util.py b/test/harness/util.py
index f5cacb4..512b92d 100644
--- a/test/harness/util.py
+++ b/test/harness/util.py
@@ -48,7 +48,7 @@ class Global:
dd_time = 0.0
bonnie_time = 0.0
mkfs_time = 0.0
- sleep_time = 0
+ sleep_time = 0.0
def dprint(*args):
@@ -313,8 +313,7 @@ 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(amt):
- time.sleep(1)
- Global.sleep_time += 1
+ sleep_some(1)
if os.path.exists(path) == present:
dprint("We are Happy :) present=%s, cnt=%d" % (present, i))
return True
@@ -330,8 +329,7 @@ def wipe_disc():
"""
# zero out the label and parition table
vprint('Running "sgdisk" and "dd" to wipe disc label, partitions, and filesystem')
- time.sleep(1)
- Global.sleep_time += 1
+ sleep_some(1)
ts = time.time()
res = run_cmd(['sgdisk', '--clear', Global.device])
te = time.time()
@@ -415,3 +413,10 @@ def run_bonnie():
if res != 0:
return (res, '%s: umount failed (%d)' % (tmp_dir, res))
return (0, 'Success')
+
+def sleep_some(s):
+ # sleep s seconds
+ ts = time.time()
+ time.sleep(s)
+ te = time.time()
+ Global.sleep_time += (te - ts)