Skip to content

Commit a6ea53a

Browse files
committed
Merge Synchronize access to pools in TestControlConn_ReconnectRefreshesRing (#1691)
2 parents a596d48 + 3fba474 commit a6ea53a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

control_ccm_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ func TestControlConn_ReconnectRefreshesRing(t *testing.T) {
117117
}
118118
}
119119

120-
pools := session.pool.hostConnPools
121-
if len(pools) != 0 {
122-
return fmt.Errorf("expected 0 connection pool but there were %v", len(pools))
120+
session.pool.mu.RLock()
121+
poolsLen := len(session.pool.hostConnPools)
122+
session.pool.mu.RUnlock()
123+
if poolsLen != 0 {
124+
return fmt.Errorf("expected 0 connection pool but there were %v", poolsLen)
123125
}
124126
return nil
125127
}
@@ -152,9 +154,11 @@ func TestControlConn_ReconnectRefreshesRing(t *testing.T) {
152154
return fmt.Errorf("expected all hosts to be UP but %v isn't", host.String())
153155
}
154156
}
155-
pools := session.pool.hostConnPools
156-
if len(pools) != len(allCcmHosts) {
157-
return fmt.Errorf("expected %v connection pool but there were %v", len(allCcmHosts), len(pools))
157+
session.pool.mu.RLock()
158+
poolsLen := len(session.pool.hostConnPools)
159+
session.pool.mu.RUnlock()
160+
if poolsLen != len(allCcmHosts) {
161+
return fmt.Errorf("expected %v connection pool but there were %v", len(allCcmHosts), poolsLen)
158162
}
159163
return nil
160164
}

0 commit comments

Comments
 (0)