(t *testing.T)
| 460 | } |
| 461 | |
| 462 | func TestConsistentHashKeyDistribution(t *testing.T) { |
| 463 | endpoints := []string{"http://10.2.0.1:8080", "http://10.2.0.2:8080", "http://10.2.0.3:8080", "http://10.2.0.4:8080", "http://10.2.0.5:8080", "http://10.2.0.6:8080", "http://10.2.0.7:8080", "http://10.2.0.8:8080", "http://10.2.0.9:8080", "http://10.2.0.10:8080"} |
| 464 | |
| 465 | stdDev1hashPerEndpoint := measureStdDev(endpoints, 1) |
| 466 | stdDev100HashesPerEndpoint := measureStdDev(endpoints, 100) |
| 467 | |
| 468 | if stdDev100HashesPerEndpoint >= stdDev1hashPerEndpoint { |
| 469 | t.Errorf("Standard deviation with 100 hashes per endpoint should be lower than with 1 hash per endpoint. 100 hashes: %f, 1 hash: %f", stdDev100HashesPerEndpoint, stdDev1hashPerEndpoint) |
| 470 | } |
| 471 | |
| 472 | if stdDev100HashesPerEndpoint >= 10 { // arbitrary target to flag accidental breaking changes. Currently is 5.93 |
| 473 | t.Errorf("Standard deviation was too high for 100 vnodes, got %f", stdDev100HashesPerEndpoint) |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | func addInflightRequests(registry *routing.EndpointRegistry, endpoint routing.LBEndpoint, count int) { |
| 478 | for i := 0; i < count; i++ { |
nothing calls this directly
no test coverage detected
searching dependent graphs…