From 1f1e8e21d81c4ff75078adc163bf2872d1b4650e Mon Sep 17 00:00:00 2001 From: Mike Spreitzer Date: Mon, 25 Jan 2021 01:44:08 -0500 Subject: [PATCH] Less demanding test cases in TestUniformDistribution Also a bug fix in the evaluation. --- .../pkg/util/shufflesharding/shufflesharding_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/staging/src/k8s.io/apiserver/pkg/util/shufflesharding/shufflesharding_test.go b/staging/src/k8s.io/apiserver/pkg/util/shufflesharding/shufflesharding_test.go index 9c728778084..ff870162400 100644 --- a/staging/src/k8s.io/apiserver/pkg/util/shufflesharding/shufflesharding_test.go +++ b/staging/src/k8s.io/apiserver/pkg/util/shufflesharding/shufflesharding_test.go @@ -206,8 +206,7 @@ func TestUniformDistribution(t *testing.T) { }{ {64, 3, 1 << uint(math.Ceil(math.Log2(float64(ff(64, 3))))+spare)}, {128, 3, ff(128, 3)}, - {128, 3, 3 * ff(128, 3)}, - {70, 4, ff(70, 4)}, + {50, 4, ff(50, 4)}, } for _, test := range tests { dealer, err := NewDealer(test.deckSize, test.handSize) @@ -233,8 +232,9 @@ func TestUniformDistribution(t *testing.T) { } handCoordinateMap[handCoordinate]++ } + numHandsSeen := len(handCoordinateMap) - t.Logf("Deck size = %v, hand size = %v, number of possible hands = %d, number of hands seen = %d, number of deals = %d, expected count range = [%v, %v]", test.deckSize, test.handSize, allCoordinateCount, len(handCoordinateMap), test.hashMax, minCount, maxCount) + t.Logf("Deck size = %v, hand size = %v, number of possible hands = %d, number of hands seen = %d, number of deals = %d, expected count range = [%v, %v]", test.deckSize, test.handSize, allCoordinateCount, numHandsSeen, test.hashMax, minCount, maxCount) // histogram maps (count of times a hand is seen) to (number of hands having that count) histogram := make(map[int]int) @@ -247,10 +247,10 @@ func TestUniformDistribution(t *testing.T) { goodSum += histogram[count] } - goodPct := 100 * float64(goodSum) / float64(allCoordinateCount) + goodPct := 100 * float64(goodSum) / float64(numHandsSeen) t.Logf("good percentage = %v, histogram = %v", goodPct, histogram) - if goodSum != allCoordinateCount { + if goodSum != numHandsSeen { t.Errorf("Only %v percent of the hands got a central count", goodPct) } }