Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Arko Dasgupta <arko@tetrate.io>
  • Loading branch information
arkodg committed Jan 4, 2023
1 parent f1f4d2d commit 7a9e8b3
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/xds/translator/ratelimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func buildRouteRateLimits(descriptorPrefix string, global *ir.GlobalRateLimit) [
action := &route.RateLimit_Action{
ActionSpecifier: &route.RateLimit_Action_GenericKey_{
GenericKey: &route.RateLimit_Action_GenericKey{
DescriptorKey: getRateLimitDescriptorKey(descriptorPrefix, rIdx, -1),
DescriptorValue: getRateLimitDescriptorValue(descriptorPrefix, rIdx, -1),
},
},
Expand Down
27 changes: 26 additions & 1 deletion internal/xds/translator/testdata/in/xds-ir/ratelimit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,33 @@ http:
requests: 5
unit: second
pathMatch:
name: "test"
exact: "foo/bar"
destinations:
- host: "1.2.3.4"
port: 50000
- name: "second-route"
rateLimit:
global:
rules:
- headerMatches:
- name: "x-user-id"
limit:
requests: 5
unit: second
pathMatch:
exact: "example"
destinations:
- host: "1.2.3.4"
port: 50000
- name: "third-route"
rateLimit:
global:
rules:
- limit:
requests: 5
unit: second
pathMatch:
exact: "test"
destinations:
- host: "1.2.3.4"
port: 50000
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,42 @@
name: first-route
outlierDetection: {}
type: STATIC
- commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 5s
dnsLookupFamily: V4_ONLY
loadAssignment:
clusterName: second-route
endpoints:
- lbEndpoints:
- endpoint:
address:
socketAddress:
address: 1.2.3.4
portValue: 50000
loadBalancingWeight: 1
locality: {}
name: second-route
outlierDetection: {}
type: STATIC
- commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 5s
dnsLookupFamily: V4_ONLY
loadAssignment:
clusterName: third-route
endpoints:
- lbEndpoints:
- endpoint:
address:
socketAddress:
address: 1.2.3.4
portValue: 50000
loadBalancingWeight: 1
locality: {}
name: third-route
outlierDetection: {}
type: STATIC
- connectTimeout: 10s
dnsLookupFamily: V4_ONLY
dnsRefreshRate: 30s
Expand Down
18 changes: 18 additions & 0 deletions internal/xds/translator/testdata/out/xds-ir/ratelimit.routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,21 @@
- name: x-user-id
stringMatch:
exact: one
- match:
path: example
route:
cluster: second-route
rateLimits:
- actions:
- requestHeaders:
descriptorKey: second-route-key-rule-0-match-0
headerName: x-user-id
- match:
path: test
route:
cluster: third-route
rateLimits:
- actions:
- genericKey:
descriptorKey: third-route-key-rule-0-match--1
descriptorValue: third-route-value-rule-0-match--1

0 comments on commit 7a9e8b3

Please sign in to comment.