Unverified Commit 33333335 authored by Sandro Jäckel's avatar Sandro Jäckel
Browse files

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>
parent c4ca94c1
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -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";