]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Test] upstream: cover SRV multi-upstream expansion
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 9 May 2026 10:10:35 +0000 (11:10 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 9 May 2026 10:10:35 +0000 (11:10 +0100)
commit5f498ac6ec710190367a8e62d9d32086cd673846
tree6bb8192a48fc34570d7abe77ec20e9a73fcc6552
parent31cf7dfeb447e7c250711fc787300b38666ef1e2
[Test] upstream: cover SRV multi-upstream expansion

Nine doctest cases drive the new SRV-as-multiple-upstreams path
without DNS, via the rspamd_upstream_srv_apply / force_alive_for_test
helpers exposed in upstream_internal.h:

- single-target expansion produces one selectable member
- 3 equal-weight targets distribute uniformly under round-robin
- SRV weight is honoured (100/100/1 ratio holds over many cycles)
- diff add: a new target appears, identity preserved for existing
- diff remove: dropped target drained out of selection
- diff weight change: distribution shifts after re-apply
- error budget is per member (rate threshold on one target leaves
  the other two alive — pre-refactor all three would have died)
- per-member latency EWMA records distinct values
- SRV parent is invisible to count and foreach

The error-budget case uses tightened limits (error_time=2ms,
max_errors=1) so the rate threshold fires comfortably above
g_usleep jitter on macOS while the test stays well under a second.
test/rspamd_cxx_unit.cxx
test/rspamd_cxx_unit_upstream_srv.hxx [new file with mode: 0644]