summaryrefslogtreecommitdiff
path: root/tests/server-tests/helpers
diff options
context:
space:
mode:
authordrebs <drebs@riseup.net>2016-11-18 18:16:41 -0200
committerdrebs <drebs@riseup.net>2016-11-22 12:57:22 -0200
commit389228df6ee52ce41cc83c2b91fe0b6572d4bc50 (patch)
tree5df46175e31ec4993e1ca9954a19b1dbdebbd663 /tests/server-tests/helpers
parent678a211ca31a7801d8bef8a74ca30feaa16af508 (diff)
use lock to avoid running multiple soledad tests (#8590)
If a soledad sync test script is already running, there's no need to run another one. This avoids having multiple test script hanging and eating up resources. We have seen this situation under development circumstances, when the soledad server has been modified in a way that the client hangs and never finishes.
Diffstat (limited to 'tests/server-tests/helpers')
-rwxr-xr-xtests/server-tests/helpers/soledad_sync.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/server-tests/helpers/soledad_sync.py b/tests/server-tests/helpers/soledad_sync.py
index b674818d..a92ec68f 100755
--- a/tests/server-tests/helpers/soledad_sync.py
+++ b/tests/server-tests/helpers/soledad_sync.py
@@ -27,6 +27,7 @@ os.environ['SKIP_TWISTED_SSL_CHECK'] = '1'
from twisted.internet import defer, reactor
from twisted.python import log
+from twisted.python.lockfile import FilesystemLock
from client_side_db import get_soledad_instance
from leap.common.events import flags
@@ -43,6 +44,13 @@ def bail(msg, exitcode):
sys.exit(exitcode)
+def obtain_lock():
+ scriptname = os.path.basename(__file__)
+ lockfile = os.path.join(tempfile.gettempdir(), scriptname + '.lock')
+ lock = FilesystemLock(lockfile)
+ return lock.lock()
+
+
def create_docs(soledad):
"""
Populates the soledad database with dummy messages, so we can exercise
@@ -65,6 +73,9 @@ if __name__ == '__main__':
if len(sys.argv) < 6:
bail(USAGE, 2)
+ if not obtain_lock():
+ bail("another instance is already running", 1)
+
uuid, token, server, cert_file, passphrase = sys.argv[1:]
s = get_soledad_instance(
uuid, passphrase, tempdir, server, cert_file, token)