swarm-controller: make the homeserver default fn pure, fixing test race

homeserver_or_configured_default read DEFAULT_HOMESERVER_ENV internally,
so its three unit tests raced each other by set_var/remove_var-ing the
same process env var with no synchronization under cargo test's default
parallelism (argus, PR #4443 review).

Take the default as a plain parameter instead of reading the env var
inside the function. The one env read moves to a new
configured_default_homeserver() helper, called once at the edge
(main.rs's startup diagnostic); homeserver_or_configured_default itself
is now pure and its tests need no env mutation at all.

Refs #4345
This commit is contained in:
atlas 2026-09-16 14:51:30 +02:00
commit 87af0f38d3
2 changed files with 44 additions and 32 deletions

View file

@ -1625,7 +1625,12 @@ async fn main() -> Result<()> {
// own doc comment), so this cannot change any request's outcome. Logged
// so an operator can tell the config landed before the slice that
// consults it does.
if matrix_account::homeserver_or_configured_default(None).is_none() {
if matrix_account::homeserver_or_configured_default(
None,
matrix_account::configured_default_homeserver(),
)
.is_none()
{
tracing::debug!(
"{}; matrix-account requests still need their own homeserver",
matrix_account::DEFAULT_HOMESERVER_ENV