Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
kacpersaw wants to merge7 commits intomain
base:main
Choose a base branch
Loading
fromkacpersaw/scaletest-smtp-mock-server

Conversation

kacpersaw
Copy link
Contributor

@kacpersawkacpersaw commentedOct 8, 2025
edited
Loading

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

  • Added mock SMTP server
  • Addedcoder scaletest smtp CLI command
  • Implemented HTTP API endpoints to retrieve messages by email
  • Added auto-purge to prevent memory issues

HTTP API Endpoints

  • GET /messages?email=<email> – Get messages sent to an email address
  • POST /purge – Clear all messages from memory

The HTTP API parses raw email messages to extract thedate,subject, andnotification ID.

Notification IDs are sent in emails like this:

<p><ahref="http://127.0.0.1:3000/settings/notifications?disabled=4e19c0ac-94e1-4532-9515-d1801aa283b2"style="color: #2563eb; text-decoration: none;">    Stop receiving emails like this</a></p>

CLI

coder scaletest smtp --host localhost --port 33199 --api-port 8080 --purge-at-count 1000

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)

@kacpersawGraphite App
Copy link
ContributorAuthor

@kacpersawkacpersawforce-pushed thekacpersaw/scaletest-smtp-mock-server branch from5830a76 to20790fcCompareOctober 8, 2025 16:02
iferr:=s.smtpServer.Start();err!=nil {
returnxerrors.Errorf("start SMTP server: %w",err)
}
s.smtpPort=s.smtpServer.PortNumber()
Copy link
Contributor

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 onNew()?

Copy link
ContributorAuthor

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 inNew(). IMO It should only be responsible for initialization. We could removeNew() and letStart() handle init instead, since we don't do any complicated stuff in there. WDYT?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@spikecurtisspikecurtisspikecurtis left review comments

At least 1 approving review is required to merge this pull request.

Assignees

@kacpersawkacpersaw

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@kacpersaw@spikecurtis

[8]ページ先頭

©2009-2025 Movatter.jp