Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
Signed-off-by: Lukasz Dziedziak <lukidzi@gmail.com>
  • Loading branch information
lukidzi committed Nov 28, 2024
1 parent f0ce5c3 commit bfa18db
Show file tree
Hide file tree
Showing 9 changed files with 289 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3952,6 +3952,7 @@ spec:
port:
description: Port defines the port to which a user makes
a request.
format: int32
type: integer
protocol:
default: tcp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3952,6 +3952,7 @@ spec:
port:
description: Port defines the port to which a user makes
a request.
format: int32
type: integer
protocol:
default: tcp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3972,6 +3972,7 @@ spec:
port:
description: Port defines the port to which a user makes
a request.
format: int32
type: integer
protocol:
default: tcp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5508,6 +5508,7 @@ spec:
port:
description: Port defines the port to which a user makes
a request.
format: int32
type: integer
protocol:
default: tcp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,56 @@ var _ = Describe("MeshPassthrough", func() {
listenersGolden: "simple.listener.golden.yaml",
clustersGolden: "simple.clusters.golden.yaml",
}),
Entry("the same protocol but different type match", testCase{
resources: []*core_xds.Resource{
{
Name: "outbound:passthrough:ipv4",
Origin: generator.OriginTransparent,
Resource: NewListenerBuilder(envoy_common.APIV3, "outbound:passthrough:ipv4").
Configure(OutboundListener("0.0.0.0", 15001, core_xds.SocketAddressProtocolTCP)).
Configure(FilterChain(NewFilterChainBuilder(envoy_common.APIV3, envoy_common.AnonymousResource).
Configure(TCPProxy("outbound_passthrough_ipv4", []envoy_common.Split{
plugins_xds.NewSplitBuilder().WithClusterName("outbound:passthrough:ipv4").WithWeight(100).Build(),
}...)),
)).MustBuild(),
},
{
Name: "outbound:passthrough:ipv6",
Origin: generator.OriginTransparent,
Resource: NewListenerBuilder(envoy_common.APIV3, "outbound:passthrough:ipv6").
Configure(OutboundListener("::", 15001, core_xds.SocketAddressProtocolTCP)).
Configure(FilterChain(NewFilterChainBuilder(envoy_common.APIV3, envoy_common.AnonymousResource).
Configure(TCPProxy("outbound_passthrough_ipv6", []envoy_common.Split{
plugins_xds.NewSplitBuilder().WithClusterName("outbound:passthrough:ipv6").WithWeight(100).Build(),
}...)),
)).MustBuild(),
},
},
singleItemRules: core_rules.SingleItemRules{
Rules: []*core_rules.Rule{
{
Subset: []core_rules.Tag{},
Conf: api.Conf{
AppendMatch: []api.Match{
{
Type: api.MatchType("Domain"),
Value: "www.gmail.com",
Port: pointer.To[uint32](80),
Protocol: api.ProtocolType("http"),
},
{
Type: api.MatchType("IP"),
Value: "10.42.0.8",
Protocol: api.ProtocolType("http"),
},
},
},
},
},
},
listenersGolden: "same-protocol.listener.golden.yaml",
clustersGolden: "same-protocol.clusters.golden.yaml",
}),
Entry("disabled on policy but enabled on mesh", testCase{
resources: []*core_xds.Resource{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ resources:
- h2c
destinationPort: 8126
prefixRanges:
- addressPrefix: 10.42.0.8
- addressPrefix: 10.42.0.9
prefixLen: 32
transportProtocol: raw_buffer
filters:
Expand All @@ -778,25 +778,25 @@ resources:
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
routeConfig:
name: meshpassthrough_http_10.42.0.8_8126
name: meshpassthrough_http_10.42.0.9_8126
virtualHosts:
- domains:
- '*'
name: 10.42.0.8
name: 10.42.0.9
routes:
- match:
prefix: /
route:
cluster: meshpassthrough_10.42.0.8_8126
statPrefix: meshpassthrough_http_10_42_0_8_8126
name: meshpassthrough_http_10.42.0.8_8126
cluster: meshpassthrough_10.42.0.9_8126
statPrefix: meshpassthrough_http_10_42_0_9_8126
name: meshpassthrough_http_10.42.0.9_8126
- filterChainMatch:
applicationProtocols:
- http/1.1
- h2c
destinationPort: 8126
prefixRanges:
- addressPrefix: 10.42.0.9
- addressPrefix: 10.42.0.8
prefixLen: 32
transportProtocol: raw_buffer
filters:
Expand All @@ -808,18 +808,18 @@ resources:
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
routeConfig:
name: meshpassthrough_http_10.42.0.9_8126
name: meshpassthrough_http_10.42.0.8_8126
virtualHosts:
- domains:
- '*'
name: 10.42.0.9
name: 10.42.0.8
routes:
- match:
prefix: /
route:
cluster: meshpassthrough_10.42.0.9_8126
statPrefix: meshpassthrough_http_10_42_0_9_8126
name: meshpassthrough_http_10.42.0.9_8126
cluster: meshpassthrough_10.42.0.8_8126
statPrefix: meshpassthrough_http_10_42_0_8_8126
name: meshpassthrough_http_10.42.0.8_8126
- filterChainMatch:
applicationProtocols:
- http/1.1
Expand Down Expand Up @@ -1006,7 +1006,7 @@ resources:
- h2c
destinationPort: 443
prefixRanges:
- addressPrefix: 10.42.0.8
- addressPrefix: 10.42.0.9
prefixLen: 32
transportProtocol: raw_buffer
filters:
Expand All @@ -1018,25 +1018,25 @@ resources:
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
routeConfig:
name: meshpassthrough_http_10.42.0.8_443
name: meshpassthrough_http_10.42.0.9_443
virtualHosts:
- domains:
- '*'
name: 10.42.0.8
name: 10.42.0.9
routes:
- match:
prefix: /
route:
cluster: meshpassthrough_10.42.0.8_443
statPrefix: meshpassthrough_http_10_42_0_8_443
name: meshpassthrough_http_10.42.0.8_443
cluster: meshpassthrough_10.42.0.9_443
statPrefix: meshpassthrough_http_10_42_0_9_443
name: meshpassthrough_http_10.42.0.9_443
- filterChainMatch:
applicationProtocols:
- http/1.1
- h2c
destinationPort: 443
prefixRanges:
- addressPrefix: 10.42.0.9
- addressPrefix: 10.42.0.8
prefixLen: 32
transportProtocol: raw_buffer
filters:
Expand All @@ -1048,18 +1048,18 @@ resources:
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
routeConfig:
name: meshpassthrough_http_10.42.0.9_443
name: meshpassthrough_http_10.42.0.8_443
virtualHosts:
- domains:
- '*'
name: 10.42.0.9
name: 10.42.0.8
routes:
- match:
prefix: /
route:
cluster: meshpassthrough_10.42.0.9_443
statPrefix: meshpassthrough_http_10_42_0_9_443
name: meshpassthrough_http_10.42.0.9_443
cluster: meshpassthrough_10.42.0.8_443
statPrefix: meshpassthrough_http_10_42_0_8_443
name: meshpassthrough_http_10.42.0.8_443
- filterChainMatch:
applicationProtocols:
- http/1.1
Expand Down Expand Up @@ -1125,7 +1125,7 @@ resources:
- http/1.1
- h2c
prefixRanges:
- addressPrefix: 10.42.0.8
- addressPrefix: 10.42.0.9
prefixLen: 32
transportProtocol: raw_buffer
filters:
Expand All @@ -1137,24 +1137,24 @@ resources:
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
routeConfig:
name: meshpassthrough_http_10.42.0.8_*
name: meshpassthrough_http_10.42.0.9_*
virtualHosts:
- domains:
- '*'
name: 10.42.0.8
name: 10.42.0.9
routes:
- match:
prefix: /
route:
cluster: meshpassthrough_10.42.0.8_*
statPrefix: meshpassthrough_http_10_42_0_8__
name: meshpassthrough_http_10.42.0.8_*
cluster: meshpassthrough_10.42.0.9_*
statPrefix: meshpassthrough_http_10_42_0_9__
name: meshpassthrough_http_10.42.0.9_*
- filterChainMatch:
applicationProtocols:
- http/1.1
- h2c
prefixRanges:
- addressPrefix: 10.42.0.9
- addressPrefix: 10.42.0.8
prefixLen: 32
transportProtocol: raw_buffer
filters:
Expand All @@ -1166,18 +1166,18 @@ resources:
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
routeConfig:
name: meshpassthrough_http_10.42.0.9_*
name: meshpassthrough_http_10.42.0.8_*
virtualHosts:
- domains:
- '*'
name: 10.42.0.9
name: 10.42.0.8
routes:
- match:
prefix: /
route:
cluster: meshpassthrough_10.42.0.9_*
statPrefix: meshpassthrough_http_10_42_0_9__
name: meshpassthrough_http_10.42.0.9_*
cluster: meshpassthrough_10.42.0.8_*
statPrefix: meshpassthrough_http_10_42_0_8__
name: meshpassthrough_http_10.42.0.8_*
- filterChainMatch:
applicationProtocols:
- http/1.1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
resources:
- name: meshpassthrough_10.42.0.8_*
resource:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
altStatName: meshpassthrough_10_42_0_8__
connectTimeout: 5s
lbPolicy: CLUSTER_PROVIDED
name: meshpassthrough_10.42.0.8_*
type: ORIGINAL_DST
- name: meshpassthrough_10.42.0.8_80
resource:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
altStatName: meshpassthrough_10_42_0_8_80
connectTimeout: 5s
lbPolicy: CLUSTER_PROVIDED
name: meshpassthrough_10.42.0.8_80
type: ORIGINAL_DST
- name: meshpassthrough_www.gmail.com_80
resource:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
altStatName: meshpassthrough_www_gmail_com_80
connectTimeout: 5s
lbPolicy: CLUSTER_PROVIDED
name: meshpassthrough_www.gmail.com_80
type: ORIGINAL_DST
Loading

0 comments on commit bfa18db

Please sign in to comment.