synapse/tests/handlers
Eric Eastwood 5a9ca1e3d9
Introduce Clock.call_when_running(...) to include logcontext by default (#18944)
Introduce `Clock.call_when_running(...)` to wrap startup code in a
logcontext, ensuring we can identify which server generated the logs.

Background:

>  Ideally, nothing from the Synapse homeserver would be logged against the `sentinel` 
>  logcontext as we want to know which server the logs came from. In practice, this is not 
>  always the case yet especially outside of request handling. 
>   
>  Global things outside of Synapse (e.g. Twisted reactor code) should run in the 
>  `sentinel` logcontext. It's only when it calls into application code that a logcontext 
>  gets activated. This means the reactor should be started in the `sentinel` logcontext, 
>  and any time an awaitable yields control back to the reactor, it should reset the 
>  logcontext to be the `sentinel` logcontext. This is important to avoid leaking the 
>  current logcontext to the reactor (which would then get picked up and associated with 
>  the next thing the reactor does). 
>
> *-- `docs/log_contexts.md`

Also adds a lint to prefer `Clock.call_when_running(...)` over
`reactor.callWhenRunning(...)`

Part of https://github.com/element-hq/synapse/issues/18905
2025-09-22 10:27:59 -05:00
..
__init__.py Reference Matrix Home Server 2014-08-12 15:10:52 +01:00
oidc_test_key.p8 JWT OIDC secrets for Sign in with Apple (#9549) 2021-03-09 15:03:37 +00:00
oidc_test_key.pub.pem JWT OIDC secrets for Sign in with Apple (#9549) 2021-03-09 15:03:37 +00:00
test_admin.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_appservice.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_auth.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_cas.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_deactivate_account.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_device.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_directory.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_e2e_keys.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_e2e_room_keys.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_federation_event.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_federation.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_message.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_oauth_delegation.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_oidc.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_password_providers.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_presence.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_profile.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_receipts.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_register.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_room_list.py Disable room list publication by default (#18175) 2025-02-24 12:06:16 +00:00
test_room_member.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_room_policy.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_room_summary.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_room.py Add missing type hints to tests.handlers. (#14680) 2022-12-16 11:53:01 +00:00
test_saml.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_send_email.py Add email.tlsname config option (#17849) 2024-12-17 18:05:38 -06:00
test_sliding_sync.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_sso.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_stats.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_sync.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_typing.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_user_directory.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_worker_lock.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00