diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/sinkloadtest.py | 22 |
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 | |||
6 | import sys | 6 | import sys |
7 | import signal | 7 | import signal |
8 | import datetime | 8 | import datetime |
9 | from threading import Timer | ||
10 | import time | ||
9 | 11 | ||
10 | def execute(cmd): | 12 | def 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 | ||
45 | def timeout(): | ||
46 | # This is not an error | ||
47 | print("Exceeded runtime. Test successfully completed.") | ||
48 | sys.stdout.flush() | ||
49 | os._exit(0) | ||
50 | |||
51 | def executionTimeout(): | ||
52 | print("Closed because execution timed out") | ||
53 | sys.stdout.flush() | ||
54 | os._exit(1) | ||
55 | |||
43 | try: | 56 | try: |
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) | ||
46 | except (KeyboardInterrupt, SystemExit): | 68 | except (KeyboardInterrupt, SystemExit): |
47 | print("Aborted with Ctrl-c") | 69 | print("Aborted with Ctrl-c") |
48 | sys.exit(0) | 70 | sys.exit(0) |