The slowest test packages spent their time waiting rather than testing. db.Params gains an optional PasswordCost (zero means bcrypt.DefaultCost), and the db, ircserver and handlers tests hash at bcrypt.MinCost. A test IRC server's relay checks its queue on broker notification instead of polling. The service and handlers tests build config.Config directly and run in parallel; config exports DefaultTrustedProxies and ParseTrustedProxies for them. Fixed sleeps give way to waits for the event. Production defaults are unchanged. What still takes time is CPU work under -race or a timeout a test is about. Model: opus-5-5
This commit was merged in pull request #267.
This commit is contained in:
1 parent
847f5c6fec
commit
ed5125606a
15 files changed
+558
-261
No files matched your search
@@ -53,6 +53,11 @@ type Server struct {
|
||||
pingInterval time.Duration
|
||||
pongDeadline time.Duration
|
||||
|
||||
// pollInterval and stopTimeout are the constants of the
|
||||
// same names, except in tests, which change them.
|
||||
pollInterval time.Duration
|
||||
stopTimeout time.Duration
|
||||
|
||||
// resolveHost is the function of the same name, except in
|
||||
// tests, which replace it with one that blocks.
|
||||
resolveHost func(ctx context.Context, addr string) string
|
||||
@@ -79,6 +84,8 @@ func New(
|
||||
|
||||
pingInterval: pingInterval,
|
||||
pongDeadline: pongDeadline,
|
||||
pollInterval: pollInterval,
|
||||
stopTimeout: stopTimeout,
|
||||
resolveHost: resolveHost,
|
||||
}
|
||||
|
||||
@@ -154,10 +161,10 @@ func (s *Server) stop() {
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(stopTimeout):
|
||||
case <-time.After(s.stopTimeout):
|
||||
s.log.Error(
|
||||
"irc connections not cleaned up before stop timeout",
|
||||
"timeout", stopTimeout,
|
||||
"timeout", s.stopTimeout,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -181,7 +188,7 @@ func (s *Server) acceptLoop(ctx context.Context) {
|
||||
|
||||
client := newConn(
|
||||
tcpConn, s.log,
|
||||
s.database, s.brk, s.cfg, s.svc,
|
||||
s.database, s.brk, s.cfg, s.svc, s.pollInterval,
|
||||
)
|
||||
|
||||
s.mu.Lock()
|
||||
|
||||
Reference in new issue
Block a user