From 33333335763f3109950ef0d9f009b8308f59bd7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Mon, 3 Jul 2023 00:19:30 +0200 Subject: [PATCH] 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> --- pkgs/servers/matrix-synapse/default.nix | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pkgs/servers/matrix-synapse/default.nix b/pkgs/servers/matrix-synapse/default.nix index 78458382c7e4..e278fc3aab00 100644 --- a/pkgs/servers/matrix-synapse/default.nix +++ b/pkgs/servers/matrix-synapse/default.nix @@ -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";