1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

Fix test.

This commit is contained in:
Vladimir Mihailenco
2015-11-22 14:44:38 +02:00
parent f130ab6161
commit b6b689904a
6 changed files with 36 additions and 29 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"math/rand"
"net"
"reflect"
"strings"
"testing"
@ -116,23 +117,23 @@ func startCluster(scenario *clusterScenario) error {
// Wait until all nodes have consistent info
for _, client := range scenario.clients {
err := eventually(func() error {
s := client.ClusterNodes().Val()
nodes := strings.Split(s, "\n")
if len(nodes) < 6 {
return fmt.Errorf("got %d nodes, wanted 6", len(nodes))
res, err := client.ClusterSlots().Result()
if err != nil {
return err
}
for _, node := range nodes {
if node == "" {
continue
}
parts := strings.Split(node, " ")
var flags string
if len(parts) >= 3 {
flags = parts[2]
}
if !strings.Contains(flags, "master") && !strings.Contains(flags, "slave") {
return fmt.Errorf("node flags are %q", flags)
wanted := []redis.ClusterSlotInfo{
{0, 4999, []string{"127.0.0.1:8220", "127.0.0.1:8223"}},
{5000, 9999, []string{"127.0.0.1:8221", "127.0.0.1:8224"}},
{10000, 16383, []string{"127.0.0.1:8222", "127.0.0.1:8225"}},
}
loop:
for _, info := range res {
for _, info2 := range wanted {
if reflect.DeepEqual(info, info2) {
continue loop
}
}
return fmt.Errorf("cluster did not reach consistent state (%v)", res)
}
return nil
}, 10*time.Second)