Преглед изворни кода

Merge pull request #5547 from xiang90/int

integration: always return active client
Xiang Li пре 9 година
родитељ
комит
755567cb3d
1 измењених фајлова са 9 додато и 1 уклоњено
  1. 9 1
      integration/cluster.go

+ 9 - 1
integration/cluster.go

@@ -795,7 +795,15 @@ func (c *ClusterV3) Terminate(t *testing.T) {
 }
 
 func (c *ClusterV3) RandClient() *clientv3.Client {
-	return c.clients[rand.Intn(len(c.clients))]
+	for i := 0; i < 100; i++ {
+		cli := c.clients[rand.Intn(len(c.clients))]
+		if cli.ActiveConnection() == nil {
+			time.Sleep(10 * time.Millisecond)
+			continue
+		}
+		return cli
+	}
+	panic("failed to get a active client")
 }
 
 func (c *ClusterV3) Client(i int) *clientv3.Client {