mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #98355 from MikeSpreitzer/smaller-sharding-test
Less demanding test cases in TestUniformDistribution
This commit is contained in:
commit
f4250198ea
@ -206,8 +206,7 @@ func TestUniformDistribution(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{64, 3, 1 << uint(math.Ceil(math.Log2(float64(ff(64, 3))))+spare)},
|
{64, 3, 1 << uint(math.Ceil(math.Log2(float64(ff(64, 3))))+spare)},
|
||||||
{128, 3, ff(128, 3)},
|
{128, 3, ff(128, 3)},
|
||||||
{128, 3, 3 * ff(128, 3)},
|
{50, 4, ff(50, 4)},
|
||||||
{70, 4, ff(70, 4)},
|
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
dealer, err := NewDealer(test.deckSize, test.handSize)
|
dealer, err := NewDealer(test.deckSize, test.handSize)
|
||||||
@ -233,8 +232,9 @@ func TestUniformDistribution(t *testing.T) {
|
|||||||
}
|
}
|
||||||
handCoordinateMap[handCoordinate]++
|
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 maps (count of times a hand is seen) to (number of hands having that count)
|
||||||
histogram := make(map[int]int)
|
histogram := make(map[int]int)
|
||||||
@ -247,10 +247,10 @@ func TestUniformDistribution(t *testing.T) {
|
|||||||
goodSum += histogram[count]
|
goodSum += histogram[count]
|
||||||
}
|
}
|
||||||
|
|
||||||
goodPct := 100 * float64(goodSum) / float64(allCoordinateCount)
|
goodPct := 100 * float64(goodSum) / float64(numHandsSeen)
|
||||||
|
|
||||||
t.Logf("good percentage = %v, histogram = %v", goodPct, histogram)
|
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)
|
t.Errorf("Only %v percent of the hands got a central count", goodPct)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user