summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-11-15 11:57:35 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-11-15 14:00:13 +0100
commit45c2e6a6be0668aa93b38f528042dc42b780d783 (patch)
tree0e4807cfda25986c19f9a0cca76f173c334c5cab
parent14cea590f52aa8b01347bc732872edae576a13c5 (diff)
downloadsink-45c2e6a6be0668aa93b38f528042dc42b780d783.tar.gz
sink-45c2e6a6be0668aa93b38f528042dc42b780d783.zip
Added timeouts to sinkloadtest
-rwxr-xr-xtests/sinkloadtest.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/sinkloadtest.py b/tests/sinkloadtest.py
index 3eff270..d5de1a8 100755
--- a/tests/sinkloadtest.py
+++ b/tests/sinkloadtest.py
@@ -6,6 +6,8 @@ import os
6import sys 6import sys
7import signal 7import signal
8import datetime 8import datetime
9from threading import Timer
10import time
9 11
10def execute(cmd): 12def execute(cmd):
11 print (str(datetime.datetime.now()) + " Running command: ", cmd) 13 print (str(datetime.datetime.now()) + " Running command: ", cmd)
@@ -40,9 +42,29 @@ def loadtest():
40 else: 42 else:
41 raise Exception("Something went wrong during the query: ", proc.returncode) 43 raise Exception("Something went wrong during the query: ", proc.returncode)
42 44
45def timeout():
46 # This is not an error
47 print("Exceeded runtime. Test successfully completed.")
48 sys.stdout.flush()
49 os._exit(0)
50
51def executionTimeout():
52 print("Closed because execution timed out")
53 sys.stdout.flush()
54 os._exit(1)
55
43try: 56try:
57 runtime = 30 * 60
58 executionTimeoutTime = 120
59 t = Timer(runtime, timeout)
60 t.start()
61 start = time.time()
44 while True: 62 while True:
63 executionTimer = Timer(executionTimeoutTime, executionTimeout)
64 executionTimer.start()
45 loadtest(); 65 loadtest();
66 executionTimer.cancel()
67 print("Running for ", time.time() - start)
46except (KeyboardInterrupt, SystemExit): 68except (KeyboardInterrupt, SystemExit):
47 print("Aborted with Ctrl-c") 69 print("Aborted with Ctrl-c")
48 sys.exit(0) 70 sys.exit(0)