fix(tests): remove SMTP-env race behind the email-notification flake (LC-363) #374
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/lc-363-email-notification-flake"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes LC-363.
Root cause
Both
email_notification_post_pathandemail_notification_dispatchbuilt their test mailer by setting the four process-globalLETS_CHAT_SMTP_*env vars, callingMailer::from_env(), then removing them - insidesetup(), which runs per test on parallel threads. Under full-suite concurrency the windows overlapped: a concurrentremove_varlanded between another test'sset_varandfrom_env(), so that test gotmailer: None, the dispatcher returnedSkippedNoMailer, no reply-token was minted, and thecount == 1assert failed. Load-sensitive, always green on isolated re-run - the exact LC-363 symptom.Fix
Add a
#[doc(hidden)]test-onlyMailer::unreachable_for_tests()that builds the same unreachable-host mailer (127.0.0.1:1, TLS none) directly, with no environment access, and use it in both test files. No process-global mutation, so the tests can no longer race. (Production still goes throughfrom_envexclusively.)Validation
just testandjust test-saasboth green on the first run (the saas suite had been flaking ~1-in-3 on these binaries before).3 files:
server/src/mail.rs,server/tests/email_notification_post_path.rs,server/tests/email_notification_dispatch.rs.