- Tests hash passwords at bcrypt.MinCost, set through the PasswordCost field of db.Params. TestPasswordCost checks the cost with and without it. - Test IRC servers check the queue only on broker notification; one test keeps the 100 ms fallback poll. - The stop-timeout test shortens the timeout through a test-only setter. - service and handlers tests build config.Config directly instead of through config.New, so they run in parallel. config exports DefaultTrustedProxies and ParseTrustedProxies for the handlers test config. - Repeated race trials run as parallel subtests. - Fixed sleeps become waits on the broker. - A new test covers the relay's failed queue read, which only the 100 ms poll had reached. Model: opus-5-5
This commit is contained in:
1 parent
f42c6214a0
commit
baaf54499d
15 files changed
+560
-263
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