New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TestRingLossy fails with drain error #60
Comments
Lines 127 to 132 in ae326c3
When the test is run with -race flag, there are multiple ring strips created and hence none of them reach capacity.
|
I see. We need another way to make sure |
Here's what I'm thinking, rather than an exact, single threaded test: func TestRingLossy(t *testing.T) {
drainCount := 0
buffer := newRingBuffer(ringLossy, &ringConfig{
Consumer: &TestConsumer{
push: func(items []uint64) {
drainCount++
},
},
Capacity: 4,
})
for i := 0; i < 100; i++ {
buffer.Push(uint64(i))
}
// ideally we'd be able to check for a certain "drop percentage" here, but
// that may vary per platform and testing configuration. for example: if
// drainCount == 20 then we have 100% accuracy, but it's most likely around
// 13-20 due to dropping and unfilled rings.
if drainCount == 0 {
t.Fatal("drain error")
}
} |
@karlmcguire I thought of doing something along similar lines. Do you mind sending a PR? I ran your snippet and I didn't see any failures after running the test for ~10m. |
TestRingLossy
fails on master with drain errorRun
to reproduce the failure
ristretto/ring_test.go
Lines 41 to 59 in ae326c3
The text was updated successfully, but these errors were encountered: