Files
go-redis/probe_internal_test.go
Nedyalko Dyakov c5cad058c7 test(tests): TCP-probe before Ping in skip gates (#4001)
Tests that skip when Redis is absent gated on a client Ping to a
hardcoded/helper address. A Ping to an addr with nothing listening does
not fail fast: it pays the dial-retry (DialerRetries, default 5) plus
command-retry budget first, ~1.7s per call. A recent RE integration
nightly spent ~1.6 min across 68 such skips.

Probe the address with a short-timeout TCP dial first, which fails in
microseconds on connection-refused, then keep the existing Ping so a
reachable-but-unusable server still skips rather than proceeds.
2026-08-31 14:18:10 +03:00

19 lines
489 B
Go

package redis
import (
"net"
"time"
)
// probeRedis is the package redis copy of the redis_test helper of the same
// name (the internal tests cannot import the external test package). See
// probe_test.go for the rationale: a fast TCP probe avoids the ~1.7s
// dial-retry + command-retry cost a Ping pays when nothing is listening.
func probeRedis(addr string) error {
c, err := net.DialTimeout("tcp", addr, 300*time.Millisecond)
if err != nil {
return err
}
return c.Close()
}