From d3c6b6f35380202e5822e7455c5bdf49c22a4778 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Sat, 21 Nov 2015 13:16:13 +0200 Subject: [PATCH] tests: check Cluster node flags. --- cluster_test.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/cluster_test.go b/cluster_test.go index bc395b44..26d306e3 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -116,11 +116,22 @@ func startCluster(scenario *clusterScenario) error { // Wait until all nodes have consistent info for _, client := range scenario.clients { err := eventually(func() error { - for _, masterId := range scenario.nodeIds[:3] { - s := client.ClusterNodes().Val() - wanted := "slave " + masterId - if !strings.Contains(s, wanted) { - return fmt.Errorf("%q does not contain %q", s, wanted) + s := client.ClusterNodes().Val() + nodes := strings.Split(s, "\n") + if len(nodes) < 6 { + return fmt.Errorf("got %d nodes, wanted 6", len(nodes)) + } + 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) } } return nil