Watch
0
0
Fork
You've already forked hyperhive
0

hive-matrix-mcp: test the secondary retry loop and the registry lock

The retry loop's body was only reachable through bring_up_account, which
needs a live homeserver, so nothing exercised what happens when a down
secondary comes up or fails, or that the Registry's new RwLock is never
held across the network call. The unit tests covered the pure decision
(DownAccounts, retry_delay) only.

retry_down now delegates to retry_loop / retry_once, which take the
bring-up step and the snapshot path as parameters; retry_down passes
bring_up_account and the real path, so behaviour is unchanged. Tests use
offline matrix-sdk clients and fake bring-ups to show that:
- a secondary that comes up is inserted, leaves the down set, has its
  sync loop sent on and is published in the snapshot, while the primary
  and the other accounts stay the same clients;
- one that fails (error or no token) stays down, is not published, and
  waits twice as long next time; one that is not yet due is not tried;
- readers are not blocked while a bring-up is pending;
- inserts under four busy reader threads neither deadlock nor lose an
  account;
- the loop, under paused time, retries at 2, 6, 14 and 30 minutes.

tokio's test-util feature is added as a dev-dependency for the last.
This commit is contained in:
atlas 2026-10-14 01:28:01 +02:00 • committed by mara
commit bd6009ff33
2 changed files with 375 additions and 30 deletions

View file

@ -32,3 +32,6 @@ tracing-subscriber.workspace = true
[[bin]]
name = "hive-matrix-daemon"
path = "src/main.rs"
[dev-dependencies]
tokio = { workspace = true, features = ["test-util"] }