Merge pull request #98355 from MikeSpreitzer/smaller-sharding-test

Less demanding test cases in TestUniformDistribution
This commit is contained in:
Kubernetes Prow Robot 2021-01-25 11:43:12 -08:00 committed by GitHub
commit f4250198ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
}
}