-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Query Frontend: dynamic horizontal query sharding (#5658)
* Adding new parameter for more dynamic horizontal query sharding Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com> * Update docs for query FE Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com> * Adding new parameters and testing validation Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com> * Using new parameters instead of changing behavior for existing ones Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com> * Adding changelog entry for changes Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com> * Fixing problem on config validation and adding more test cases Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com> * Fixing linting Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com> * Change name of cli arguments and improve validation Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com> * Fixing changelog entry Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com> * Final touches on docs Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com> * Adding params names to changelog Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com> * Fixing CR comments Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com> * Adding additional check for minimal split interval Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com> Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
- Loading branch information
1 parent
fb11fc7
commit 0392dd7
Showing
7 changed files
with
249 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// Copyright (c) The Thanos Authors. | ||
// Licensed under the Apache License 2.0. | ||
|
||
package queryfrontend | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
"github.com/thanos-io/thanos/internal/cortex/chunk/cache" | ||
"github.com/thanos-io/thanos/internal/cortex/querier/queryrange" | ||
"github.com/thanos-io/thanos/pkg/testutil" | ||
) | ||
|
||
func TestConfig_Validate(t *testing.T) { | ||
|
||
type testCase struct { | ||
name string | ||
config Config | ||
err string | ||
} | ||
|
||
testCases := []testCase{ | ||
{ | ||
name: "invalid query range options", | ||
config: Config{ | ||
QueryRangeConfig: QueryRangeConfig{ | ||
SplitQueriesByInterval: 10 * time.Hour, | ||
HorizontalShards: 10, | ||
MinQuerySplitInterval: 1 * time.Hour, | ||
MaxQuerySplitInterval: day, | ||
}, | ||
}, | ||
err: "split queries interval and dynamic query split interval cannot be set at the same time", | ||
}, | ||
{ | ||
name: "invalid parameters for dynamic query range split", | ||
config: Config{ | ||
QueryRangeConfig: QueryRangeConfig{ | ||
SplitQueriesByInterval: 0, | ||
HorizontalShards: 0, | ||
MinQuerySplitInterval: 1 * time.Hour, | ||
}, | ||
}, | ||
err: "min horizontal shards should be greater than 0 when query split threshold is enabled", | ||
}, | ||
{ | ||
name: "invalid parameters for dynamic query range split - 2", | ||
config: Config{ | ||
QueryRangeConfig: QueryRangeConfig{ | ||
SplitQueriesByInterval: 0, | ||
HorizontalShards: 10, | ||
MaxQuerySplitInterval: 0, | ||
MinQuerySplitInterval: 1 * time.Hour, | ||
}, | ||
}, | ||
err: "max query split interval should be greater than 0 when query split threshold is enabled", | ||
}, | ||
{ | ||
name: "invalid parameters for dynamic query range split - 3", | ||
config: Config{ | ||
QueryRangeConfig: QueryRangeConfig{ | ||
SplitQueriesByInterval: 0, | ||
HorizontalShards: 10, | ||
MaxQuerySplitInterval: 1 * time.Hour, | ||
MinQuerySplitInterval: 0, | ||
}, | ||
LabelsConfig: LabelsConfig{ | ||
DefaultTimeRange: day, | ||
}, | ||
}, | ||
err: "min query split interval should be greater than 0 when query split threshold is enabled", | ||
}, | ||
{ | ||
name: "valid config with caching", | ||
config: Config{ | ||
DownstreamURL: "localhost:8080", | ||
QueryRangeConfig: QueryRangeConfig{ | ||
SplitQueriesByInterval: 10 * time.Hour, | ||
HorizontalShards: 0, | ||
MaxQuerySplitInterval: 0, | ||
MinQuerySplitInterval: 0, | ||
ResultsCacheConfig: &queryrange.ResultsCacheConfig{ | ||
CacheConfig: cache.Config{}, | ||
Compression: "", | ||
CacheQueryableSamplesStats: false, | ||
}, | ||
}, | ||
LabelsConfig: LabelsConfig{ | ||
DefaultTimeRange: day, | ||
}, | ||
}, | ||
err: "", | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
err := tc.config.Validate() | ||
if tc.err != "" { | ||
testutil.NotOk(t, err) | ||
testutil.Equals(t, tc.err, err.Error()) | ||
} else { | ||
testutil.Ok(t, err) | ||
fmt.Println(err) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters