MCPcopy Create free account
hub / github.com/zalando/skipper / TestConsistentHashKeyDistribution

Function TestConsistentHashKeyDistribution

loadbalancer/algorithm_test.go:462–475  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

460}
461
462func 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
477func addInflightRequests(registry *routing.EndpointRegistry, endpoint routing.LBEndpoint, count int) {
478 for i := 0; i < count; i++ {

Callers

nothing calls this directly

Calls 2

measureStdDevFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…