feat(cli): add mock SMTP server for testing scaletest notifications#20221
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.
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.
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.
Like:
srv := new(Server)
err = srv.Start(ctx, config)
I think that's fine.
spikecurtis
left a comment
There was a problem hiding this comment.
Minor suggestion inline, but I don't need to review again.
| // Notification ID is present in the email footer like this | ||
| // <p><a href=3D"http://127.0.0.1:3000/settings/notifications?disabled=3D | ||
| // =3D4e19c0ac-94e1-4532-9515-d1801aa283b2" style=3D"color: #2563eb; text-deco= | ||
| // ration: none;">Stop receiving emails like this</a></p> |
There was a problem hiding this comment.
this comment is still in quotedprintable encoding, which makes it harder to understand.
dc3c69d to
adc1c9f
Compare
Merge activity
|

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 smtpCLI 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)