Skip to content

Commit

Permalink
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 Nov 17, 2022
1 parent 4e35015 commit 2af765e
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 0 deletions.
23 changes: 23 additions & 0 deletions internal/xds/translator/testdata/in/xds-ir/ratelimit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
http:
- name: "first-listener"
address: "0.0.0.0"
port: 10080
hostnames:
- "*"
routes:
- name: "first-route"
rateLimit:
global:
rules:
- headerMatches:
- name: "x-user-id"
exact: "one"
limit:
requests: 5
unit: second
pathMatch:
name: "test"
exact: "foo/bar"
destinations:
- host: "1.2.3.4"
port: 50000
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
- commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 5s
dnsLookupFamily: V4_ONLY
loadAssignment:
clusterName: first-route
endpoints:
- lbEndpoints:
- endpoint:
address:
socketAddress:
address: 1.2.3.4
portValue: 50000
loadBalancingWeight: 1
locality: {}
name: first-route
outlierDetection: {}
type: STATIC
- connectTimeout: 10s
dnsLookupFamily: V4_ONLY
dnsRefreshRate: 30s
http2ProtocolOptions: {}
lbPolicy: RANDOM
loadAssignment:
clusterName: ratelimit_cluster
endpoints:
- lbEndpoints:
- endpoint:
address:
socketAddress:
address: TODO
portValue: 0
name: ratelimit_cluster
respectDnsTtl: true
type: STRICT_DNS
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
- accessLog:
- filter:
responseFlagFilter:
flags:
- NR
name: envoy.access_loggers.file
typedConfig:
'@type': type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
portValue: 10080
defaultFilterChain:
filters:
- name: envoy.filters.network.http_connection_manager
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
accessLog:
- name: envoy.access_loggers.file
typedConfig:
'@type': type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: /dev/stdout
httpFilters:
- name: envoy.filters.http.ratelimit
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.ratelimit.v3.RateLimit
domain: first-listener
rateLimitService:
grpcService:
envoyGrpc:
clusterName: ratelimit_cluster
transportApiVersion: V3
- name: envoy.filters.http.router
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
rds:
configSource:
apiConfigSource:
apiType: DELTA_GRPC
grpcServices:
- envoyGrpc:
clusterName: xds_cluster
setNodeOnFirstMessageOnly: true
transportApiVersion: V3
resourceApiVersion: V3
routeConfigName: first-listener
statPrefix: http
name: first-listener
19 changes: 19 additions & 0 deletions internal/xds/translator/testdata/out/xds-ir/ratelimit.routes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- name: first-listener
virtualHosts:
- domains:
- '*'
name: first-listener
routes:
- match:
path: foo/bar
route:
cluster: first-route
rateLimits:
- actions:
- headerValueMatch:
descriptorValue: first-route-value-rule-0-match-0
expectMatch: true
headers:
- name: x-user-id
stringMatch:
exact: one
3 changes: 3 additions & 0 deletions internal/xds/translator/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ func TestTranslate(t *testing.T) {
{
name: "http2-route",
},
{
name: "ratelimit",
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 2af765e

Please sign in to comment.