Skip to content

Commit d590128

Browse files
committed
Update tests and changelog
Signed-off-by: Essam Eldaly <eeldaly@amazon.com>
1 parent 7878a8c commit d590128

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* [ENHANCEMENT] Distributor: Add a label references validation for remote write v2 request. #7074
99
* [ENHANCEMENT] Distributor: Add count, spans, and buckets validations for native histogram. #7072
1010
* [ENHANCEMENT] Ruler: Add DecodingConcurrency config flag for Thanos Engine. #7118
11+
* [ENHANCEMENT] Query Frontend: Add query priority based on operation. #7127
1112
* [BUGFIX] Ring: Change DynamoDB KV to retry indefinitely for WatchKey. #7088
1213
* [BUGFIX] Ruler: Add XFunctions validation support. #7111
1314

pkg/querier/tripperware/query_attribute_matcher_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,3 +706,45 @@ func Test_matchAttributeForExpressionQueryShouldMatchUserAgentRegex(t *testing.T
706706
}
707707

708708
}
709+
710+
func Test_rejectQueryOrSetPriorityShouldMatchOnApiType(t *testing.T) {
711+
712+
limits := mockLimits{queryPriority: validation.QueryPriority{
713+
Priorities: []validation.PriorityDef{
714+
{
715+
Priority: 7,
716+
QueryAttributes: []validation.QueryAttribute{
717+
{
718+
ApiType: "metadata",
719+
},
720+
},
721+
},
722+
},
723+
},
724+
}
725+
726+
type testCase struct {
727+
path string
728+
expectedPriority int64
729+
}
730+
731+
tests := map[string]testCase{
732+
"should set priority based on api type": {
733+
path: "/api/v1/targets/metadata?limit=1",
734+
expectedPriority: 7,
735+
},
736+
}
737+
738+
for testName, testData := range tests {
739+
t.Run(testName, func(t *testing.T) {
740+
req, err := http.NewRequest("GET", testData.path, http.NoBody)
741+
require.NoError(t, err)
742+
reqStats, ctx := stats.ContextWithEmptyStats(context.Background())
743+
req = req.WithContext(ctx)
744+
limits.queryPriority.Enabled = true
745+
resultErr := rejectQueryOrSetPriority(req, time.Now(), time.Duration(1), limits, "", rejectedQueriesPerTenant)
746+
assert.NoError(t, resultErr)
747+
assert.Equal(t, testData.expectedPriority, reqStats.Priority)
748+
})
749+
}
750+
}

0 commit comments

Comments
 (0)