summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@riseup.net>2016-11-18 18:03:26 -0200
committerdrebs <drebs@riseup.net>2016-11-22 12:57:16 -0200
commit678a211ca31a7801d8bef8a74ca30feaa16af508 (patch)
treec045e310dfe6bfec407072e8e5de5823b40ba8fd
parent34a381efa8f6295080c843f86bfa07d4e41056af (diff)
add a timeout for the soledad sync test script (#8590)
If for any reason a sync takes too long, the script will timeout and log an errro.
-rwxr-xr-xtests/server-tests/helpers/soledad_sync.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/server-tests/helpers/soledad_sync.py b/tests/server-tests/helpers/soledad_sync.py
index f4fc81ae..b674818d 100755
--- a/tests/server-tests/helpers/soledad_sync.py
+++ b/tests/server-tests/helpers/soledad_sync.py
@@ -35,6 +35,7 @@ flags.set_events_enabled(False)
NUMDOCS = 1
USAGE = "Usage: %s uuid token server cert_file password" % sys.argv[0]
+SYNC_TIMEOUT = 60
def bail(msg, exitcode):
@@ -68,12 +69,23 @@ if __name__ == '__main__':
s = get_soledad_instance(
uuid, passphrase, tempdir, server, cert_file, token)
+ def syncWithTimeout(_):
+ d = s.sync()
+ reactor.callLater(SYNC_TIMEOUT, d.cancel)
+ return d
+
def onSyncDone(sync_result):
print "SYNC_RESULT:", sync_result
s.close()
rm_tempdir()
reactor.stop()
+ def trap_cancel(f):
+ f.trap(defer.CancelledError)
+ log.err("sync timed out after %s seconds" % SYNC_TIMEOUT)
+ rm_tempdir()
+ reactor.stop()
+
def log_and_exit(f):
log.err(f)
rm_tempdir()
@@ -81,8 +93,9 @@ if __name__ == '__main__':
def start_sync():
d = create_docs(s)
- d.addCallback(lambda _: s.sync())
+ d.addCallback(syncWithTimeout)
d.addCallback(onSyncDone)
+ d.addErrback(trap_cancel)
d.addErrback(log_and_exit)
reactor.callWhenRunning(start_sync)