瀏覽代碼

Fix TestTokenAwareConnPool to wait for full pool.

It was depending on the synchronous pool filling before.
Muir Manders 9 年之前
父節點
當前提交
e204266169
共有 1 個文件被更改,包括 12 次插入2 次删除
  1. 12 2
      cassandra_test.go

+ 12 - 2
cassandra_test.go

@@ -1920,8 +1920,18 @@ func TestTokenAwareConnPool(t *testing.T) {
 	session := createSessionFromCluster(cluster, t)
 	defer session.Close()
 
-	if expected := cluster.NumConns * len(session.ring.allHosts()); session.pool.Size() != expected {
-		t.Errorf("Expected pool size %d but was %d", expected, session.pool.Size())
+	expectedPoolSize := cluster.NumConns * len(session.ring.allHosts())
+
+	// wait for pool to fill
+	for i := 0; i < 10; i++ {
+		if session.pool.Size() == expectedPoolSize {
+			break
+		}
+		time.Sleep(100 * time.Millisecond)
+	}
+
+	if expectedPoolSize != session.pool.Size() {
+		t.Errorf("Expected pool size %d but was %d", expectedPoolSize, session.pool.Size())
 	}
 
 	// add another cf so there are two pages when fetching table metadata from our keyspace