summaryrefslogtreecommitdiffstats
path: root/tests/sinkloadtest.py
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-11-01 23:28:59 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-11-03 13:54:24 +0100
commitc5495c22418fc6da2ebdc98a24156dea701b3b3e (patch)
treec6b6de7bacb82a2968dba45409ebdf91735a0744 /tests/sinkloadtest.py
parent32ef7ac7d9314483d08f926277aba12eed765d07 (diff)
downloadsink-c5495c22418fc6da2ebdc98a24156dea701b3b3e.tar.gz
sink-c5495c22418fc6da2ebdc98a24156dea701b3b3e.zip
sinkloadtest.py
Diffstat (limited to 'tests/sinkloadtest.py')
-rwxr-xr-xtests/sinkloadtest.py48
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
3import subprocess
4import shlex
5import os
6import sys
7import signal
8import datetime
9
10def 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
18def run(cmd, printOutput = False):
19 execute(cmd)
20
21def 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
43try:
44 while True:
45 loadtest();
46except (KeyboardInterrupt, SystemExit):
47 print("Aborted with Ctrl-c")
48 sys.exit(0)