diff options
author | drebs <drebs@leap.se> | 2017-04-05 13:45:46 +0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2017-04-15 13:11:54 +0200 |
commit | 639569f611963d8b876f7705accba4b88a1c871d (patch) | |
tree | 2503f1d3e6024de71c06d57d5a221364c39eab01 | |
parent | 8a1d160f9e753b8a201bca964b44df3832d3bee8 (diff) |
[test] enforce bundled pysqlcipher in benchmark tests
The debian package for libsqlcipher does not enable the use of usleep(),
and that might cause timeouts when doing concurrent access to sqlcipher
databases.
See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=859685
In benchmark tests we use twisted's asynchronous dbapi for creating
thousands of documents, and if usleep() is not enabled this operation is
very likelly to fail with a "db is locked" error.
This commit adds a workaround for benchmark tests by reinstalling
pysqlcipher with the "--bundled" option, what causes libsqlcipher to be
built and bundled in the python package, with usleep() enabled.
Resolves: #8835
-rwxr-xr-x | testing/check-pysqlcipher.py | 23 | ||||
-rw-r--r-- | testing/tox.ini | 9 |
2 files changed, 31 insertions, 1 deletions
diff --git a/testing/check-pysqlcipher.py b/testing/check-pysqlcipher.py new file mode 100755 index 00000000..4202b13b --- /dev/null +++ b/testing/check-pysqlcipher.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +import os +import tempfile + +from pysqlcipher import dbapi2 + + +def have_usleep(): + fname = tempfile.mktemp() + db = dbapi2.connect(fname) + cursor = db.cursor() + cursor.execute('PRAGMA compile_options;') + options = map(lambda t: t[0], cursor.fetchall()) + db.close() + os.unlink(fname) + return u'HAVE_USLEEP' in options + + +if __name__ == '__main__': + if not have_usleep(): + raise Exception('pysqlcipher was not built with HAVE_USLEEP flag.') + print "All ok, pysqlcipher was built with HAVE_USLEEP flag. :-)" diff --git a/testing/tox.ini b/testing/tox.ini index 2acbf4fb..48c1afb9 100644 --- a/testing/tox.ini +++ b/testing/tox.ini @@ -67,7 +67,14 @@ deps = git+https://github.com/drebs/pytest-benchmark.git@fix-update-machine-info-hook-spec elasticsearch certifi -commands = py.test --benchmark-only {posargs} +commands = +# use a bundled version of pysqlcipher to ensure HAVE_USLEEP is set and we +# don't have problems with concurrent db access. + pip uninstall -y pysqlcipher + pip install --install-option="--bundled" pysqlcipher + ./check-pysqlcipher.py +# and only then run benchmark + py.test --benchmark-only {posargs} passenv = HOST_HOSTNAME [testenv:code-check] |