@@ -42,7 +42,6 @@ import (
42
42
"github.com/coder/coder/v2/scaletest/loadtestutil"
43
43
"github.com/coder/coder/v2/scaletest/notifications"
44
44
"github.com/coder/coder/v2/scaletest/reconnectingpty"
45
- "github.com/coder/coder/v2/scaletest/smtpmock"
46
45
"github.com/coder/coder/v2/scaletest/workspacebuild"
47
46
"github.com/coder/coder/v2/scaletest/workspacetraffic"
48
47
"github.com/coder/coder/v2/scaletest/workspaceupdates"
@@ -2176,101 +2175,6 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
2176
2175
return cmd
2177
2176
}
2178
2177
2179
- func (* RootCmd )scaletestSMTP ()* serpent.Command {
2180
- var (
2181
- hostAddress string
2182
- smtpPort int64
2183
- apiPort int64
2184
- purgeAtCount int64
2185
- )
2186
- cmd := & serpent.Command {
2187
- Use :"smtp" ,
2188
- Short :"Start a mock SMTP server for testing" ,
2189
- Long :`Start a mock SMTP server with an HTTP API server that can be used to purge
2190
- messages and get messages by email.` ,
2191
- Handler :func (inv * serpent.Invocation )error {
2192
- ctx := inv .Context ()
2193
- notifyCtx ,stop := signal .NotifyContext (ctx ,StopSignals ... )
2194
- defer stop ()
2195
- ctx = notifyCtx
2196
-
2197
- logger := slog .Make (sloghuman .Sink (inv .Stderr )).Leveled (slog .LevelInfo )
2198
- srv := smtpmock .New (smtpmock.Config {
2199
- HostAddress :hostAddress ,
2200
- SMTPPort :int (smtpPort ),
2201
- APIPort :int (apiPort ),
2202
- Logger :logger ,
2203
- })
2204
-
2205
- if err := srv .Start (ctx );err != nil {
2206
- return xerrors .Errorf ("start mock SMTP server: %w" ,err )
2207
- }
2208
- defer func () {
2209
- _ = srv .Stop ()
2210
- }()
2211
-
2212
- _ ,_ = fmt .Fprintf (inv .Stdout ,"Mock SMTP server started on %s\n " ,srv .SMTPAddress ())
2213
- _ ,_ = fmt .Fprintf (inv .Stdout ,"HTTP API server started on %s\n " ,srv .APIAddress ())
2214
- if purgeAtCount > 0 {
2215
- _ ,_ = fmt .Fprintf (inv .Stdout ," Auto-purge when message count reaches %d\n " ,purgeAtCount )
2216
- }
2217
-
2218
- ticker := time .NewTicker (10 * time .Second )
2219
- defer ticker .Stop ()
2220
-
2221
- for {
2222
- select {
2223
- case <- ctx .Done ():
2224
- _ ,_ = fmt .Fprintf (inv .Stdout ,"\n Total messages received since last purge: %d\n " ,srv .MessageCount ())
2225
- return nil
2226
- case <- ticker .C :
2227
- count := srv .MessageCount ()
2228
- if count > 0 {
2229
- _ ,_ = fmt .Fprintf (inv .Stdout ,"Messages received: %d\n " ,count )
2230
- }
2231
-
2232
- if purgeAtCount > 0 && int64 (count )>= purgeAtCount {
2233
- _ ,_ = fmt .Fprintf (inv .Stdout ,"Message count (%d) reached threshold (%d). Purging...\n " ,count ,purgeAtCount )
2234
- srv .Purge ()
2235
- continue
2236
- }
2237
- }
2238
- }
2239
- },
2240
- }
2241
-
2242
- cmd .Options = []serpent.Option {
2243
- {
2244
- Flag :"host-address" ,
2245
- Env :"CODER_SCALETEST_SMTP_HOST" ,
2246
- Default :"localhost" ,
2247
- Description :"Host to bind the mock SMTP and API servers." ,
2248
- Value :serpent .StringOf (& hostAddress ),
2249
- },
2250
- {
2251
- Flag :"smtp-port" ,
2252
- Env :"CODER_SCALETEST_SMTP_PORT" ,
2253
- Description :"Port for the mock SMTP server. Uses a random port if not specified." ,
2254
- Value :serpent .Int64Of (& smtpPort ),
2255
- },
2256
- {
2257
- Flag :"api-port" ,
2258
- Env :"CODER_SCALETEST_SMTP_API_PORT" ,
2259
- Description :"Port for the HTTP API server. Uses a random port if not specified." ,
2260
- Value :serpent .Int64Of (& apiPort ),
2261
- },
2262
- {
2263
- Flag :"purge-at-count" ,
2264
- Env :"CODER_SCALETEST_SMTP_PURGE_AT_COUNT" ,
2265
- Default :"100000" ,
2266
- Description :"Maximum number of messages to keep before auto-purging. Set to 0 to disable." ,
2267
- Value :serpent .Int64Of (& purgeAtCount ),
2268
- },
2269
- }
2270
-
2271
- return cmd
2272
- }
2273
-
2274
2178
type runnableTraceWrapper struct {
2275
2179
tracer trace.Tracer
2276
2180
spanName string