Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Ye <benye@amazon.com>
  • Loading branch information
yeya24 committed Nov 1, 2022
1 parent 6541e10 commit 51c6348
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions pkg/queryfrontend/roundtrip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func TestRoundTripRetryMiddleware(t *testing.T) {
Start: 0,
End: 2 * hour,
Step: 10 * seconds,
Query: "foo",
}

testLabelsRequest := &ThanosLabelsRequest{Path: "/api/v1/labels", Start: 0, End: 2 * hour}
Expand Down Expand Up @@ -222,6 +223,7 @@ func TestRoundTripSplitIntervalMiddleware(t *testing.T) {
Start: 0,
End: 2 * hour,
Step: 10 * seconds,
Query: "foo",
}

testLabelsRequest := &ThanosLabelsRequest{
Expand Down Expand Up @@ -395,6 +397,7 @@ func TestRoundTripQueryRangeCacheMiddleware(t *testing.T) {
Step: 10 * seconds,
MaxSourceResolution: 1 * seconds,
Dedup: true, // Deduplication is enabled by default.
Query: "foo",
}

testRequestWithoutDedup := &ThanosQueryRangeRequest{
Expand All @@ -404,6 +407,7 @@ func TestRoundTripQueryRangeCacheMiddleware(t *testing.T) {
Step: 10 * seconds,
MaxSourceResolution: 1 * seconds,
Dedup: false,
Query: "foo",
}

// Same query params as testRequest, different maxSourceResolution
Expand All @@ -415,6 +419,7 @@ func TestRoundTripQueryRangeCacheMiddleware(t *testing.T) {
Step: 10 * seconds,
MaxSourceResolution: 10 * seconds,
Dedup: true,
Query: "foo",
}

// Same query params as testRequest, different maxSourceResolution
Expand All @@ -426,6 +431,7 @@ func TestRoundTripQueryRangeCacheMiddleware(t *testing.T) {
Step: 10 * seconds,
MaxSourceResolution: 1 * hour,
Dedup: true,
Query: "foo",
}

// Same query params as testRequest, but with storeMatchers
Expand All @@ -437,6 +443,7 @@ func TestRoundTripQueryRangeCacheMiddleware(t *testing.T) {
MaxSourceResolution: 1 * seconds,
StoreMatchers: [][]*labels.Matcher{{labels.MustNewMatcher(labels.MatchEqual, "foo", "bar")}},
Dedup: true,
Query: "foo",
}

cacheConf := &queryrange.ResultsCacheConfig{
Expand Down Expand Up @@ -487,6 +494,7 @@ func TestRoundTripQueryRangeCacheMiddleware(t *testing.T) {
End: 25 * hour,
Step: 10 * seconds,
Dedup: true,
Query: "foo",
},
expected: 6,
},
Expand All @@ -498,6 +506,7 @@ func TestRoundTripQueryRangeCacheMiddleware(t *testing.T) {
End: 25 * hour,
Step: 10 * seconds,
Dedup: true,
Query: "foo",
},
expected: 6,
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/queryfrontend/split_by_interval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ func TestSplitQuery(t *testing.T) {
},
} {
t.Run(strconv.Itoa(i), func(t *testing.T) {
days, err := splitQuery(tc.input, tc.interval)
queries, err := splitQuery(tc.input, tc.interval)
require.NoError(t, err)
require.Equal(t, tc.expected, days)
require.Equal(t, tc.expected, queries)
})
}
}

0 comments on commit 51c6348

Please sign in to comment.