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

[r332] frontend: Add integration test for split and cache middleware #10811

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions integration/query_frontend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
configFile, flags := cfg.setup(t, s)

flags = mergeFlags(flags, map[string]string{
"-querier.max-partial-query-length": "30d",
"-query-frontend.cache-results": "true",
"-query-frontend.results-cache.backend": "memcached",
"-query-frontend.results-cache.memcached.addresses": "dns+" + memcached.NetworkEndpoint(e2ecache.MemcachedPort),
Expand Down Expand Up @@ -364,6 +365,16 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
c, err := e2emimir.NewClient("", queryFrontend.HTTPEndpoint(), "", "", fmt.Sprintf("user-%d", userID))
require.NoError(t, err)

// Do a long query to test the split and cache middleware.
if userID == 0 {
require.NoError(t, queryFrontend.WaitSumMetrics(e2e.Equals(0), "cortex_frontend_split_queries_total"))
end := time.Now()
start := end.Add(-(30*24*time.Hour + 1*time.Hour)) // 30 days + 1 hour. Makes sure we can go above the max partial query length.
_, err = c.QueryRange("{instance=~\"hello.*\"}", start, end, time.Hour)
require.NoError(t, err)
require.NoError(t, queryFrontend.WaitSumMetrics(e2e.Equals(31), "cortex_frontend_split_queries_total"))
}

// No need to repeat the test on start/end time rounding for each user.
if userID == 0 {
start := time.Unix(1595846748, 806*1e6)
Expand Down Expand Up @@ -397,6 +408,7 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
require.Len(t, result, 0)
}

// Test subquery spin-off.
if userID == 0 {
require.NoError(t, queryFrontend.WaitSumMetrics(e2e.Equals(0), "cortex_frontend_spun_off_subqueries_total"))
result, err := c.Query("sum_over_time(((count(series_1) * count(series_1)) or vector(1))[6h:15m])", now)
Expand All @@ -422,10 +434,11 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
wg.Wait()

// Compute the expected number of queries.
expectedQueriesCount := float64(numUsers*numQueriesPerUser) + 3
expectedQueriesCount := float64(numUsers*numQueriesPerUser) + 4
// The "time()" query and the query with time range < "query ingesters within" are not pushed down to ingesters.
// +1 because one split query ends up touching the ingester.
// +2 because the spun off subquery ends up as additional ingester queries.
expectedIngesterQueriesCount := float64(numUsers*numQueriesPerUser) + 2
expectedIngesterQueriesCount := float64(numUsers*numQueriesPerUser) + 3
if cfg.queryStatsEnabled {
expectedQueriesCount++
expectedIngesterQueriesCount++
Expand Down
Loading