diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-11-01 23:28:59 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-11-03 13:54:24 +0100 |
commit | c5495c22418fc6da2ebdc98a24156dea701b3b3e (patch) | |
tree | c6b6de7bacb82a2968dba45409ebdf91735a0744 /tests | |
parent | 32ef7ac7d9314483d08f926277aba12eed765d07 (diff) | |
download | sink-c5495c22418fc6da2ebdc98a24156dea701b3b3e.tar.gz sink-c5495c22418fc6da2ebdc98a24156dea701b3b3e.zip |
sinkloadtest.py
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/sinkloadtest.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/sinkloadtest.py b/tests/sinkloadtest.py new file mode 100755 index 0000000..3eff270 --- /dev/null +++ b/tests/sinkloadtest.py | |||
@@ -0,0 +1,48 @@ | |||
1 | #!/usr/bin/python3 | ||
2 | |||
3 | import subprocess | ||
4 | import shlex | ||
5 | import os | ||
6 | import sys | ||
7 | import signal | ||
8 | import datetime | ||
9 | |||
10 | def execute(cmd): | ||
11 | print (str(datetime.datetime.now()) + " Running command: ", cmd) | ||
12 | popen = subprocess.Popen(shlex.split(cmd), universal_newlines=True, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) | ||
13 | (stdoutdata, stderrdata) = popen.communicate() | ||
14 | if popen.returncode: | ||
15 | raise Exception("Something went wrong while running the command:", popen.returncode) | ||
16 | return stdoutdata | ||
17 | |||
18 | def run(cmd, printOutput = False): | ||
19 | execute(cmd) | ||
20 | |||
21 | def loadtest(): | ||
22 | resourceName = "kolabnowImap" | ||
23 | run("sinksh create resource type sink.imap identifier {} server imaps://imap.kolabnow.com:993 username test1@kolab.org".format(resourceName)) | ||
24 | run("sinksh clear {}".format(resourceName)) | ||
25 | run("sinksh sync folder {} --password Welcome2KolabSystems".format(resourceName), printOutput = True) | ||
26 | |||
27 | try: | ||
28 | proc = subprocess.Popen(shlex.split("sinksh livequery mail --resource {}".format(resourceName))) | ||
29 | |||
30 | run("sinksh sync mail {}/INBOX --password Welcome2KolabSystems".format(resourceName), printOutput = True) | ||
31 | |||
32 | finally: | ||
33 | proc.terminate() | ||
34 | proc.communicate() | ||
35 | #returncode -15 means signal 15 has terminated the process | ||
36 | sig = -proc.returncode | ||
37 | if sig != signal.SIGTERM: | ||
38 | if sig == signal.SIGINT: | ||
39 | raise KeyboardInterrupt() | ||
40 | else: | ||
41 | raise Exception("Something went wrong during the query: ", proc.returncode) | ||
42 | |||
43 | try: | ||
44 | while True: | ||
45 | loadtest(); | ||
46 | except (KeyboardInterrupt, SystemExit): | ||
47 | print("Aborted with Ctrl-c") | ||
48 | sys.exit(0) | ||