From c5495c22418fc6da2ebdc98a24156dea701b3b3e Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 1 Nov 2017 23:28:59 +0100 Subject: sinkloadtest.py --- tests/sinkloadtest.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 tests/sinkloadtest.py 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 @@ +#!/usr/bin/python3 + +import subprocess +import shlex +import os +import sys +import signal +import datetime + +def execute(cmd): + print (str(datetime.datetime.now()) + " Running command: ", cmd) + popen = subprocess.Popen(shlex.split(cmd), universal_newlines=True, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) + (stdoutdata, stderrdata) = popen.communicate() + if popen.returncode: + raise Exception("Something went wrong while running the command:", popen.returncode) + return stdoutdata + +def run(cmd, printOutput = False): + execute(cmd) + +def loadtest(): + resourceName = "kolabnowImap" + run("sinksh create resource type sink.imap identifier {} server imaps://imap.kolabnow.com:993 username test1@kolab.org".format(resourceName)) + run("sinksh clear {}".format(resourceName)) + run("sinksh sync folder {} --password Welcome2KolabSystems".format(resourceName), printOutput = True) + + try: + proc = subprocess.Popen(shlex.split("sinksh livequery mail --resource {}".format(resourceName))) + + run("sinksh sync mail {}/INBOX --password Welcome2KolabSystems".format(resourceName), printOutput = True) + + finally: + proc.terminate() + proc.communicate() + #returncode -15 means signal 15 has terminated the process + sig = -proc.returncode + if sig != signal.SIGTERM: + if sig == signal.SIGINT: + raise KeyboardInterrupt() + else: + raise Exception("Something went wrong during the query: ", proc.returncode) + +try: + while True: + loadtest(); +except (KeyboardInterrupt, SystemExit): + print("Aborted with Ctrl-c") + sys.exit(0) -- cgit v1.2.3