-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(cli): add mock SMTP server for testing scaletest notifications #20221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
5830a76
to
20790fc
Compare
if err := s.smtpServer.Start(); err != nil { | ||
return xerrors.Errorf("start SMTP server: %w", err) | ||
} | ||
s.smtpPort = s.smtpServer.PortNumber() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are doing this so that you can leave the port initially set to 0 and then later query the running port. It feels like a sharp edge, though, that s.SMTPAddress() will show you a 0 port until you start the server. Is there any reason why we don't want to just start the server immediately on New()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of allocating ports in New()
. IMO It should only be responsible for initialization. We could remove New()
and let Start()
handle init instead, since we don't do any complicated stuff in there. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like:
srv := new(Server)
err = srv.Start(ctx, config)
I think that's fine.
This PR adds a fake SMTP server for scale testing. It collects emails sent during tests, which you can then check using the HTTP API.
Changes
coder scaletest smtp
CLI commandHTTP API Endpoints
GET /messages?email=<email>
– Get messages sent to an email addressPOST /purge
– Clear all messages from memoryThe HTTP API parses raw email messages to extract the date, subject, and notification ID.
Notification IDs are sent in emails like this:
CLI
Flags:
--host
: Host for the mock SMTP and API server (default: localhost)--port
: Port for the mock SMTP server (random if not specified)--api-port
: Port for the HTTP API server (random if not specified)--purge-at-count
: Max number of messages before auto-purging (default: 100000)