1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Make sentinel tests more reliable.

This commit is contained in:
Vladimir Mihailenco
2015-01-30 16:45:57 +02:00
parent 15a90c831b
commit 7f87de6109
3 changed files with 22 additions and 9 deletions

View File

@ -140,18 +140,19 @@ func execCmd(name string, args ...string) (*os.Process, error) {
}
func connectTo(port string) (client *redis.Client, err error) {
client = redis.NewTCPClient(&redis.Options{
client = redis.NewClient(&redis.Options{
Addr: ":" + port,
})
deadline := time.Now().Add(time.Second)
for time.Now().Before(deadline) {
if err = client.Ping().Err(); err == nil {
break
return client, nil
}
time.Sleep(100 * time.Millisecond)
}
return
return nil, err
}
type redisProcess struct {
@ -199,7 +200,7 @@ func startSentinel(port, masterName, masterPort string) (*redisProcess, error) {
return nil, err
}
}
return &redisProcess{process, client}, err
return &redisProcess{process, client}, nil
}
//------------------------------------------------------------------------------