mirror of
https://github.com/alibaba/higress.git
synced 2026-05-26 13:47:27 +08:00
feat: ai-token-ratelimit support setting global rate limit thresholds for routes (#2667)
This commit is contained in:
@@ -20,6 +20,16 @@ func TestParseClusterKeyRateLimitConfig(t *testing.T) {
|
||||
json: `{}`,
|
||||
expectedErr: errors.New("missing rule_name in config"),
|
||||
},
|
||||
{
|
||||
name: "GlobalThreshold_InvalidThreshold",
|
||||
json: `{
|
||||
"rule_name": "invalid-threshold",
|
||||
"global_threshold": {
|
||||
"query_per_minute": -100
|
||||
}
|
||||
}`,
|
||||
expectedErr: errors.New("failed to parse global_threshold: 'query_per_minute' must be a positive integer, got -100"),
|
||||
},
|
||||
{
|
||||
name: "GlobalThreshold_QueryPerSecond",
|
||||
json: `{
|
||||
@@ -56,6 +66,21 @@ func TestParseClusterKeyRateLimitConfig(t *testing.T) {
|
||||
RejectedMsg: DefaultRejectedMsg,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "RuleItems_InvalidThreshold",
|
||||
json: `{
|
||||
"rule_name": "invalid-threshold",
|
||||
"rule_items": [
|
||||
{
|
||||
"limit_by_header": "x-test",
|
||||
"limit_keys": [
|
||||
{"key": "key1", "query_per_minute": -100}
|
||||
]
|
||||
}
|
||||
]
|
||||
}`,
|
||||
expectedErr: errors.New("failed to parse rule_item in rule_items: 'query_per_minute' must be a positive integer for key 'key1', got -100"),
|
||||
},
|
||||
{
|
||||
name: "RuleItems_SingleRule",
|
||||
json: `{
|
||||
|
||||
Reference in New Issue
Block a user