matrix-synapse: limit parallelism to 4 cores to be improve stability, formatting

On high core machines those easily can fail similar to:

matrix-synapse> tests.storage.test_room_search.MessageSearchTest.test_postgres_web_search_for_phrase
matrix-synapse> ===============================================================================
matrix-synapse> [ERROR]
matrix-synapse> Traceback (most recent call last):
matrix-synapse>   File "/build/source/tests/unittest.py", line 122, in new
matrix-synapse>     return code(orig, *args, **kwargs)
matrix-synapse>   File "/build/source/tests/unittest.py", line 216, in setUp
matrix-synapse>     return orig()
matrix-synapse>   File "/build/source/tests/unittest.py", line 338, in setUp
matrix-synapse>     self.hs = self.make_homeserver(self.reactor, self.clock)
matrix-synapse>   File "/build/source/tests/app/test_openid_listener.py", line 34, in make_homeserver
matrix-synapse>     hs = self.setup_test_homeserver(
matrix-synapse>   File "/build/source/tests/unittest.py", line 606, in setup_test_homeserver
matrix-synapse>     hs = setup_test_homeserver(self.addCleanup, **kwargs)
matrix-synapse>   File "/build/source/tests/server.py", line 921, in setup_test_homeserver
matrix-synapse>     prepare_database(
matrix-synapse>   File "/nix/store/2cc0p5apn2yg2fr5ii9mvb7fcwd74y26-matrix-synapse-1.86.0/lib/python3.10/site-packages/synapse/storage/prepare_database.py", line 155, in prepare_database
matrix-synapse>     raise UpgradeDatabaseException(EMPTY_DATABASE_ON_WORKER_ERROR)
matrix-synapse> synapse.storage.prepare_database.UpgradeDatabaseException: Uninitialised database: run the main synapse process to prepare the database schema before starting worker processes.
matrix-synapse>
This commit is contained in:
Sandro Jäckel 2023-07-03 00:19:30 +02:00
parent c4ca94c154
commit 3333333576
No known key found for this signature in database
GPG Key ID: 3AF5A43A3EECC2E5

View File

@ -86,21 +86,29 @@ buildPythonApplication rec {
doCheck = !stdenv.isDarwin;
checkPhase = let testFlags = lib.optionalString (!stdenv.isAarch64) "-j $NIX_BUILD_CORES"; in ''
checkPhase = ''
runHook preCheck
# remove src module, so tests use the installed module instead
rm -rf ./synapse
PYTHONPATH=".:$PYTHONPATH" ${python3.interpreter} -m twisted.trial ${testFlags} tests
# high parallelisem makes test suite unstable
# upstream uses 2 cores but 4 seems to be also stable
# https://github.com/matrix-org/synapse/blob/develop/.github/workflows/latest_deps.yml#L103
if (( $NIX_BUILD_CORES > 4)); then
NIX_BUILD_CORES=4
fi
PYTHONPATH=".:$PYTHONPATH" ${python3.interpreter} -m twisted.trial -j $NIX_BUILD_CORES tests
runHook postCheck
'';
passthru.tests = { inherit (nixosTests) matrix-synapse; };
passthru.plugins = plugins;
passthru.tools = tools;
passthru.python = python3;
passthru = {
tests = { inherit (nixosTests) matrix-synapse; };
inherit plugins tools;
python = python3;
};
meta = with lib; {
homepage = "https://matrix.org";