Skip to content

Commit

Permalink
Some more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Lior Okman <[email protected]>
  • Loading branch information
liorokman committed Dec 18, 2024
1 parent 570bacf commit 2357622
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/xds/translator/extensionserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,17 @@ func (t *testingExtensionServer) PostHTTPListenerModify(_ context.Context, req *

// PostTranslateModifyHook inserts and overrides some clusters/secrets
func (t *testingExtensionServer) PostTranslateModify(_ context.Context, req *pb.PostTranslateModifyRequest) (*pb.PostTranslateModifyResponse, error) {
for _, cluster := range req.Clusters {
if edsConfig := cluster.GetEdsClusterConfig(); edsConfig != nil {
if strings.Contains(edsConfig.ServiceName, "fail-close-error") {
return &pb.PostTranslateModifyResponse{
Clusters: req.Clusters,
Secrets: req.Secrets,
}, fmt.Errorf("cluster hook resource error: %s", edsConfig.ServiceName)
}
}
}

extensionSvcEndpoint := &endpointV3.LbEndpoint_Endpoint{
Endpoint: &endpointV3.Endpoint{
Address: &coreV3.Address{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
http:
- name: "extension-post-xdstranslate-hook-error"
address: "0.0.0.0"
port: 10080
hostnames:
- "*"
path:
mergeSlashes: true
escapedSlashesAction: UnescapeAndRedirect
routes:
- name: "first-route"
hostname: "*"
pathMatch:
prefix: "/"
destination:
name: "fail-close-error"
settings:
- endpoints:
- host: "1.2.3.4"
port: 50000
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- circuitBreakers:
thresholds:
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
dnsLookupFamily: V4_PREFERRED
edsClusterConfig:
edsConfig:
ads: {}
resourceApiVersion: V3
serviceName: fail-close-error
ignoreHealthOnHostRemoval: true
lbPolicy: LEAST_REQUEST
name: fail-close-error
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- clusterName: fail-close-error
endpoints:
- lbEndpoints:
- endpoint:
address:
socketAddress:
address: 1.2.3.4
portValue: 50000
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: fail-close-error/backend/0
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
- 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
commonHttpProtocolOptions:
headersWithUnderscoresAction: REJECT_REQUEST
http2ProtocolOptions:
initialConnectionWindowSize: 1048576
initialStreamWindowSize: 65536
maxConcurrentStreams: 100
httpFilters:
- name: envoy.filters.http.router
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
suppressEnvoyHeaders: true
mergeSlashes: true
normalizePath: true
pathWithEscapedSlashesAction: UNESCAPE_AND_REDIRECT
routeConfig:
name: error_route_configuration
virtualHosts:
- domains:
- '*'
name: error_vhost
routes:
- directResponse:
status: 500
match:
prefix: /
name: error_route
serverHeaderTransformation: PASS_THROUGH
statPrefix: http-10080
useRemoteAddress: true
name: extension-post-xdstranslate-hook-error
name: extension-post-xdstranslate-hook-error
perConnectionBufferLimitBytes: 32768
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- ignorePortInHostMatching: true
name: extension-post-xdstranslate-hook-error
virtualHosts:
- domains:
- '*'
name: extension-post-xdstranslate-hook-error/*
routes:
- match:
prefix: /
name: first-route
route:
cluster: fail-close-error
upgradeConfigs:
- upgradeType: websocket
3 changes: 3 additions & 0 deletions internal/xds/translator/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ func TestTranslateXdsWithExtension(t *testing.T) {
"http-route-extension-listener-error": {
errMsg: "rpc error: code = Unknown desc = extension post xds listener hook error",
},
"http-route-extension-translate-error": {
errMsg: "rpc error: code = Unknown desc = cluster hook resource error: fail-close-error",
},
}

inputFiles, err := filepath.Glob(filepath.Join("testdata", "in", "extension-xds-ir", "*.yaml"))
Expand Down

0 comments on commit 2357622

Please sign in to comment.