Skip to content

Commit

Permalink
fix flaky retention tests (#4697) (#4698)
Browse files Browse the repository at this point in the history
(cherry picked from commit 20726e6)

Co-authored-by: Sandeep Sukhani <[email protected]>
  • Loading branch information
grafanabot and sandeepsukhani authored Nov 8, 2021
1 parent 56792bb commit f61a4d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions pkg/storage/stores/shipper/compactor/retention/retention_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ func TestMarkForDelete_SeriesCleanup(t *testing.T) {
{
name: "no chunk and series deleted",
chunks: []chunk.Chunk{
createChunk(t, userID, labels.Labels{labels.Label{Name: "foo", Value: "1"}}, now.Add(-30*time.Minute), now),
createChunk(t, userID, labels.Labels{labels.Label{Name: "foo", Value: "1"}}, todaysTableInterval.Start, todaysTableInterval.Start.Add(30*time.Minute)),
},
expiry: []chunkExpiry{
{
Expand All @@ -482,7 +482,7 @@ func TestMarkForDelete_SeriesCleanup(t *testing.T) {
{
name: "only one chunk in store which gets deleted",
chunks: []chunk.Chunk{
createChunk(t, userID, labels.Labels{labels.Label{Name: "foo", Value: "1"}}, now.Add(-30*time.Minute), now),
createChunk(t, userID, labels.Labels{labels.Label{Name: "foo", Value: "1"}}, todaysTableInterval.Start, todaysTableInterval.Start.Add(30*time.Minute)),
},
expiry: []chunkExpiry{
{
Expand All @@ -502,14 +502,14 @@ func TestMarkForDelete_SeriesCleanup(t *testing.T) {
{
name: "only one chunk in store which gets partially deleted",
chunks: []chunk.Chunk{
createChunk(t, userID, labels.Labels{labels.Label{Name: "foo", Value: "1"}}, now.Add(-30*time.Minute), now),
createChunk(t, userID, labels.Labels{labels.Label{Name: "foo", Value: "1"}}, todaysTableInterval.Start, todaysTableInterval.Start.Add(30*time.Minute)),
},
expiry: []chunkExpiry{
{
isExpired: true,
nonDeletedIntervals: []model.Interval{{
Start: now.Add(-15 * time.Minute),
End: now,
Start: todaysTableInterval.Start,
End: todaysTableInterval.Start.Add(15 * time.Minute),
}},
},
},
Expand All @@ -526,8 +526,8 @@ func TestMarkForDelete_SeriesCleanup(t *testing.T) {
{
name: "one of two chunks deleted",
chunks: []chunk.Chunk{
createChunk(t, userID, labels.Labels{labels.Label{Name: "foo", Value: "1"}}, now.Add(-30*time.Minute), now),
createChunk(t, userID, labels.Labels{labels.Label{Name: "foo", Value: "2"}}, now.Add(-30*time.Minute), now),
createChunk(t, userID, labels.Labels{labels.Label{Name: "foo", Value: "1"}}, todaysTableInterval.Start, todaysTableInterval.Start.Add(30*time.Minute)),
createChunk(t, userID, labels.Labels{labels.Label{Name: "foo", Value: "2"}}, todaysTableInterval.Start, todaysTableInterval.Start.Add(30*time.Minute)),
},
expiry: []chunkExpiry{
{
Expand All @@ -550,8 +550,8 @@ func TestMarkForDelete_SeriesCleanup(t *testing.T) {
{
name: "one of two chunks partially deleted",
chunks: []chunk.Chunk{
createChunk(t, userID, labels.Labels{labels.Label{Name: "foo", Value: "1"}}, now.Add(-30*time.Minute), now),
createChunk(t, userID, labels.Labels{labels.Label{Name: "foo", Value: "2"}}, now.Add(-30*time.Minute), now),
createChunk(t, userID, labels.Labels{labels.Label{Name: "foo", Value: "1"}}, todaysTableInterval.Start, todaysTableInterval.Start.Add(30*time.Minute)),
createChunk(t, userID, labels.Labels{labels.Label{Name: "foo", Value: "2"}}, todaysTableInterval.Start, todaysTableInterval.Start.Add(30*time.Minute)),
},
expiry: []chunkExpiry{
{
Expand All @@ -560,8 +560,8 @@ func TestMarkForDelete_SeriesCleanup(t *testing.T) {
{
isExpired: true,
nonDeletedIntervals: []model.Interval{{
Start: now.Add(-15 * time.Minute),
End: now,
Start: todaysTableInterval.Start,
End: todaysTableInterval.Start.Add(15 * time.Minute),
}},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

func dayFromTime(t model.Time) chunk.DayTime {
parsed, err := time.Parse("2006-01-02", t.Time().Format("2006-01-02"))
parsed, err := time.Parse("2006-01-02", t.Time().In(time.UTC).Format("2006-01-02"))
if err != nil {
panic(err)
}
Expand Down

0 comments on commit f61a4d2

Please sign in to comment.