MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestCleanUnhealthy

Function TestCleanUnhealthy

pkg/ring/client/pool_test.go:122–147  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

120}
121
122func TestCleanUnhealthy(t *testing.T) {
123 goodAddrs := []string{"good1", "good2"}
124 badAddrs := []string{"bad1", "bad2"}
125 clients := map[string]PoolClient{}
126 for _, addr := range goodAddrs {
127 clients[addr] = mockClient{happy: true, status: grpc_health_v1.HealthCheckResponse_SERVING}
128 }
129 for _, addr := range badAddrs {
130 clients[addr] = mockClient{happy: false, status: grpc_health_v1.HealthCheckResponse_NOT_SERVING}
131 }
132 pool := &Pool{
133 clients: clients,
134 logger: log.NewNopLogger(),
135 }
136 pool.cleanUnhealthy()
137 for _, addr := range badAddrs {
138 if _, ok := pool.clients[addr]; ok {
139 t.Errorf("Found bad client after clean: %s\n", addr)
140 }
141 }
142 for _, addr := range goodAddrs {
143 if _, ok := pool.clients[addr]; !ok {
144 t.Errorf("Could not find good client after clean: %s\n", addr)
145 }
146 }
147}

Callers

nothing calls this directly

Calls 1

cleanUnhealthyMethod · 0.95

Tested by

no test coverage detected