(t *testing.T)
| 281 | } |
| 282 | |
| 283 | func TestLifecycler_InstancesInZoneCount(t *testing.T) { |
| 284 | t.Parallel() |
| 285 | |
| 286 | ringStore, closer := consul.NewInMemoryClient(GetCodec(), log.NewNopLogger(), nil) |
| 287 | t.Cleanup(func() { assert.NoError(t, closer.Close()) }) |
| 288 | |
| 289 | var ringConfig Config |
| 290 | flagext.DefaultValues(&ringConfig) |
| 291 | ringConfig.KVStore.Mock = ringStore |
| 292 | |
| 293 | instances := []struct { |
| 294 | zone string |
| 295 | healthy bool |
| 296 | expectedInstancesInZoneCount int |
| 297 | expectedInstancesCount int |
| 298 | expectedHealthyInstancesCount int |
| 299 | expectedZonesCount int |
| 300 | expectedHealthyInstancesInZoneCount int |
| 301 | }{ |
| 302 | { |
| 303 | zone: "zone-a", |
| 304 | healthy: true, |
| 305 | // after adding a healthy instance in zone-a, expectedInstancesInZoneCount in zone-a becomes 1 |
| 306 | expectedInstancesInZoneCount: 1, |
| 307 | // after adding a healthy instance in zone-a, expectedInstancesCount becomes 1 |
| 308 | expectedInstancesCount: 1, |
| 309 | // after adding a healthy instance in zone-a, expectedHealthyInstancesCount becomes 1 |
| 310 | expectedHealthyInstancesCount: 1, |
| 311 | // after adding a healthy instance in zone-a, expectedZonesCount is 1 |
| 312 | expectedZonesCount: 1, |
| 313 | // after adding a healthy instance in zone-a, expectedHealthyInstancesInZoneCount is 1 |
| 314 | expectedHealthyInstancesInZoneCount: 1, |
| 315 | }, |
| 316 | { |
| 317 | zone: "zone-a", |
| 318 | healthy: false, |
| 319 | // after adding an unhealthy instance in zone-a, expectedInstancesInZoneCount in zone-a becomes 2 |
| 320 | expectedInstancesInZoneCount: 2, |
| 321 | // after adding an unhealthy instance in zone-a, expectedInstancesCount becomes 2 |
| 322 | expectedInstancesCount: 2, |
| 323 | // after adding an unhealthy instance in zone-a, expectedHealthyInstancesCount remains 1 |
| 324 | expectedHealthyInstancesCount: 1, |
| 325 | // zone-a was already added, so expectedZonesCount remains 1 |
| 326 | expectedZonesCount: 1, |
| 327 | // after adding an unhealthy instance in zone-a, expectedHealthyInstancesInZoneCount remains 1 |
| 328 | expectedHealthyInstancesInZoneCount: 1, |
| 329 | }, |
| 330 | { |
| 331 | zone: "zone-a", |
| 332 | healthy: true, |
| 333 | // after adding a healthy instance in zone-a, expectedInstancesInZoneCount in zone-a becomes 3 |
| 334 | expectedInstancesInZoneCount: 3, |
| 335 | // after adding a healthy instance in zone-a, expectedInstancesCount becomes 3 |
| 336 | expectedInstancesCount: 3, |
| 337 | // after adding a healthy instance in zone-a, expectedHealthyInstancesCount becomes 2 |
| 338 | expectedHealthyInstancesCount: 2, |
| 339 | // zone-a was already added, so expectedZonesCount remains 1 |
| 340 | expectedZonesCount: 1, |
nothing calls this directly
no test coverage detected