(t *testing.T)
| 216 | } |
| 217 | |
| 218 | func TestGetHostConcurrent(t *testing.T) { |
| 219 | c := &cluster{ |
| 220 | replicas: []*replica{ |
| 221 | { |
| 222 | hosts: []*topology.Node{ |
| 223 | topology.NewNode(&url.URL{Host: "127.0.0.1"}, nil, "", "", topology.WithDefaultActiveState(true)), |
| 224 | topology.NewNode(&url.URL{Host: "127.0.0.2"}, nil, "", "", topology.WithDefaultActiveState(true)), |
| 225 | topology.NewNode(&url.URL{Host: "127.0.0.3"}, nil, "", "", topology.WithDefaultActiveState(true)), |
| 226 | }, |
| 227 | }, |
| 228 | }, |
| 229 | } |
| 230 | f := func() { |
| 231 | h := c.getHost() |
| 232 | h.IncrementConnections() |
| 233 | h.DecrementConnections() |
| 234 | } |
| 235 | if err := testConcurrent(f, 1000); err != nil { |
| 236 | t.Fatalf("concurrent test err: %s", err) |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | func testConcurrent(f func(), concurrency int) error { |
| 241 | ch := make(chan struct{}, concurrency) |
nothing calls this directly
no test coverage detected