diff --git a/.github/workflows/famedly-tests.yml b/.github/workflows/famedly-tests.yml index 8d55b50fca..6af8a86eb1 100644 --- a/.github/workflows/famedly-tests.yml +++ b/.github/workflows/famedly-tests.yml @@ -240,7 +240,11 @@ jobs: run: until pg_isready -h localhost; do sleep 1; done # coverage is already installed from the pyproject.toml file - run: poetry run pip install coverage-enable-subprocess - - run: poetry run coverage run -m twisted.trial -j6 tests + # Normally, this Github runner has 2 cores(actually threads) available to it. + # Using only one trial test runner does not saturate the cpu. Rough experimentation in the past led to having 3 + # of these runners per core as optimal, but now coverage is required and there may be the need + # to scale back a little. This should be 6 trial test runners/jobs + - run: poetry run coverage run -m twisted.trial -j$((`nproc` * 3 )) tests env: SYNAPSE_POSTGRES: ${{ matrix.job.database == 'postgres' || '' }} SYNAPSE_POSTGRES_HOST: /var/run/postgresql diff --git a/tests/handlers/test_worker_lock.py b/tests/handlers/test_worker_lock.py index 6e9a15c8ee..d01641b297 100644 --- a/tests/handlers/test_worker_lock.py +++ b/tests/handlers/test_worker_lock.py @@ -54,8 +54,11 @@ def test_wait_for_lock_locally(self) -> None: def test_lock_contention(self) -> None: """Test lock contention when a lot of locks wait on a single worker""" - # It takes around 0.5s on a 5+ years old laptop - with test_timeout(5): + # It takes around 0.5s on a 5+ years old laptop when tests are not heavily + # concurrent. The database load(even with sqlite in memory) seems to hit a wall + # after `nproc` * 4 number of jobs. Increasing the timeout allows all the + # database reads/writes to actually complete + with test_timeout(15): nb_locks = 500 d = self._take_locks(nb_locks) self.assertEqual(self.get_success(d), nb_locks) diff --git a/tests/rest/admin/test_user.py b/tests/rest/admin/test_user.py index a35a250975..35fda847cd 100644 --- a/tests/rest/admin/test_user.py +++ b/tests/rest/admin/test_user.py @@ -23,7 +23,6 @@ import hmac import json import os -import time import urllib.parse from binascii import unhexlify from http import HTTPStatus @@ -5531,12 +5530,14 @@ def test_redact_messages_all_rooms(self) -> None: id = channel.json_body.get("redact_id") timeout_s = 10 - start_time = time.time() + start_time = self.clock.time() redact_result = "" while redact_result != "complete": - if start_time + timeout_s < time.time(): + if start_time + timeout_s < self.clock.time(): self.fail("Timed out waiting for redactions.") + # It's a background task, give it a shot at actually finishing + self.pump() channel2 = self.make_request( "GET", f"/_synapse/admin/v1/user/redact_status/{id}",