-
Notifications
You must be signed in to change notification settings - Fork 817
Fix flaky chunk tests by being explicit about now
#656
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
Conversation
`dummyChunkFor` was consulting the system clock itself. This meant that tests like `TestChunkStore_Get` would intermittently fail, because _sometimes_ the created chunks would have timestamps outside the window chosen within `TestChunkStore_Get` (which itself consults the system clock). This fixes the tests by making `now` a parameter of `dummyChunkFor`, which makes the created chunks deterministic. It also adds a `now` parameter to `dummyChunk`, which isn't strictly necessary, but I believe is less error prone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no reason to suppose it's a problem, but it did strike me that you had removed a lot of uncertainty but left some still.
pkg/chunk/by_key_test.go
Outdated
@@ -102,7 +102,7 @@ func TestNWayIntersect(t *testing.T) { | |||
} | |||
|
|||
func BenchmarkByKeyLess(b *testing.B) { | |||
a := ByKey{dummyChunk(), dummyChunk()} | |||
a := ByKey{dummyChunk(model.Now()), dummyChunk(model.Now())} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even more deterministic to use the same value for these two calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be. I'd like to communicate that the value doesn't matter and that the values can be different.
pkg/chunk/chunk_test.go
Outdated
@@ -139,10 +139,10 @@ func TestChunksToMatrix(t *testing.T) { | |||
"bar": "baz", | |||
"toms": "code", | |||
} | |||
chunk1 := dummyChunkFor(metric) | |||
chunk1 := dummyChunkFor(model.Now(), metric) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even more deterministic to use the same value of now
here as at the beginning of the function?
pkg/chunk/chunk_test.go
Outdated
@@ -196,7 +196,7 @@ func TestChunksToMatrix(t *testing.T) { | |||
|
|||
func benchmarkChunk() Chunk { | |||
// This is a real example from Kubernetes' embedded cAdvisor metrics, lightly obfuscated | |||
return dummyChunkFor(model.Metric{ | |||
return dummyChunkFor(model.Now(), model.Metric{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect now
should be a parameter here so the benchmark can be as consistent as it wants to be
pkg/chunk/chunk_test.go
Outdated
@@ -157,7 +157,7 @@ func TestChunksToMatrix(t *testing.T) { | |||
"bar": "baz", | |||
"toms": "code", | |||
} | |||
chunk3 := dummyChunkFor(otherMetric) | |||
chunk3 := dummyChunkFor(model.Now(), otherMetric) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto here on using same now
pkg/chunk/chunk_test.go
Outdated
chunk1Samples, err := chunk1.Samples(chunk1.From, chunk1.Through) | ||
require.NoError(t, err) | ||
chunk2 := dummyChunkFor(metric) | ||
chunk2 := dummyChunkFor(model.Now(), metric) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto here on using same now
- Be even more deterministic by sharing `now` values - Be even more deterministic by making benchmark chunk factory accept a `now` value
pkg/ingester/ingester_lifecycle.go
Outdated
@@ -127,6 +127,8 @@ func (i *Ingester) Shutdown() { | |||
} | |||
|
|||
func (i *Ingester) loop() { | |||
level.Debug(util.Logger).Log("msg", "we get logs in failed tests") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this meant to be here?
Oops, no. That's from this morning's efforts to debug #369. Well spotted,
thanks.
…On Tue, 16 Jan 2018 at 14:37 Bryan Boreham ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pkg/ingester/ingester_lifecycle.go
<#656 (comment)>:
> @@ -127,6 +127,8 @@ func (i *Ingester) Shutdown() {
}
func (i *Ingester) loop() {
+ level.Debug(util.Logger).Log("msg", "we get logs in failed tests")
is this meant to be here?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#656 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAHq6jj_czoNnm5P8zjMRyF5zBmbA1o9ks5tLLQQgaJpZM4RfeVM>
.
|
dummyChunkFor
was consulting the system clock itself. This meant that testslike
TestChunkStore_Get
would intermittently fail, because sometimes thecreated chunks would have timestamps outside the window chosen within
TestChunkStore_Get
(which itself consults the system clock).This fixes the tests by making
now
a parameter ofdummyChunkFor
, whichmakes the created chunks deterministic.
It also adds a
now
parameter todummyChunk
, which isn't strictlynecessary, but I believe is less error prone.
Fixes #646
Thanks to @bboreham for the hint about
chunksToMatrix
, which helped narrow this down.