Skip to content
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

Test: Fix test in compactor/retention/expiration_test.go on slow machines #5137

Merged
merged 1 commit into from
Jan 14, 2022
Merged

Conversation

piggynl
Copy link
Contributor

@piggynl piggynl commented Jan 13, 2022

What this PR does / why we need it:
The "just expired tenant" test requires the corresponding e.Expired to be called within 0.01ms with previous code, and which fails on low performance devices.

tests := []struct {
name string
ref ChunkEntry
want bool
}{
{"expired tenant", newChunkEntry("1", `{foo="buzz"}`, model.Now().Add(-3*time.Hour), model.Now().Add(-2*time.Hour)), true},
{"just expired tenant", newChunkEntry("1", `{foo="buzz"}`, model.Now().Add(-3*time.Hour), model.Now().Add(-1*time.Hour+(10*time.Microsecond))), false},
{"not expired tenant", newChunkEntry("1", `{foo="buzz"}`, model.Now().Add(-3*time.Hour), model.Now().Add(-30*time.Minute)), false},
{"not expired tenant by far", newChunkEntry("2", `{foo="buzz"}`, model.Now().Add(-72*time.Hour), model.Now().Add(-3*time.Hour)), false},
{"expired stream override", newChunkEntry("2", `{foo="bar"}`, model.Now().Add(-12*time.Hour), model.Now().Add(-10*time.Hour)), true},
{"non expired stream override", newChunkEntry("1", `{foo="bar"}`, model.Now().Add(-3*time.Hour), model.Now().Add(-90*time.Minute)), false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
actual, nonDeletedIntervals := e.Expired(tt.ref, model.Now())
require.Equal(t, tt.want, actual)
require.Nil(t, nonDeletedIntervals)
})
}

Which issue(s) this PR fixes:
None

Special notes for your reviewer:
None

Checklist

  • Documentation added - not needed
  • Tests updated
  • Add an entry in the CHANGELOG.md about the changes.

@piggynl piggynl requested a review from a team as a code owner January 13, 2022 15:35
Signed-off-by: Piggy NL <piggynl@outlook.com>
@CLAassistant
Copy link

CLAassistant commented Jan 13, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cyriltovena cyriltovena merged commit e5dcade into grafana:main Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants