summaryrefslogtreecommitdiffstats
path: root/storperf/test_executor.py
diff options
context:
space:
mode:
Diffstat (limited to 'storperf/test_executor.py')
-rw-r--r--storperf/test_executor.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/storperf/test_executor.py b/storperf/test_executor.py
index d1ad3ca..8230174 100644
--- a/storperf/test_executor.py
+++ b/storperf/test_executor.py
@@ -18,6 +18,8 @@ import copy
import imp
import logging
import os
+import sched
+import time
class UnknownWorkload(Exception):
@@ -31,6 +33,7 @@ class TestExecutor(object):
self.workload_modules = []
self.filename = None
self.precondition = True
+ self.deadline = None
self.warm = True
self._queue_depths = [1, 4, 8]
self._block_sizes = [512, 4096, 16384]
@@ -143,6 +146,10 @@ class TestExecutor(object):
def terminate(self):
self._terminated = True
+ return self.terminate_current_run()
+
+ def terminate_current_run(self):
+ self.logger.info("Terminating current run")
terminated_hosts = []
for workload in self._workload_executors:
workload.terminate()
@@ -170,9 +177,17 @@ class TestExecutor(object):
for blocksize in blocksizes:
for iodepth in iodepths:
+ scheduler = sched.scheduler(time.time, time.sleep)
if self._terminated:
return
+ if self.deadline is not None \
+ and not workload_name.startswith("_"):
+ event = scheduler.enter(self.deadline * 60, 1,
+ self.terminate_current_run, ())
+ t = Thread(target=scheduler.run, args=())
+ t.start()
+
workload.options['iodepth'] = str(iodepth)
workload.options['bs'] = str(blocksize)
@@ -192,6 +207,12 @@ class TestExecutor(object):
for slave_thread in slave_threads:
slave_thread.join()
+ if not scheduler.empty():
+ try:
+ scheduler.cancel(event)
+ except:
+ pass
+
self._workload_executors = []
def execute_on_node(self, workload):