Skip to content

Commit

Permalink
add IPv6 test cases
Browse files Browse the repository at this point in the history
Signed-off-by: zirain <[email protected]>
  • Loading branch information
zirain committed Oct 31, 2024
1 parent fad8e95 commit fa1d082
Show file tree
Hide file tree
Showing 10 changed files with 1,392 additions and 14 deletions.
43 changes: 30 additions & 13 deletions internal/xds/bootstrap/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,26 +165,43 @@ func TestGetRenderedBootstrapConfig(t *testing.T) {

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got, err := GetRenderedBootstrapConfig(tc.opts)
require.NoError(t, err)

if *overrideTestData {
// nolint:gosec
err = os.WriteFile(path.Join("testdata", "render", fmt.Sprintf("%s.yaml", tc.name)), []byte(got), 0o644)
// IPv4
{
got, err := GetRenderedBootstrapConfig(tc.opts)
require.NoError(t, err)
return

if *overrideTestData {
// nolint:gosec
err = os.WriteFile(path.Join("testdata", "render", fmt.Sprintf("%s.yaml", tc.name)), []byte(got), 0o644)
require.NoError(t, err)
} else {
expected, err := readTestData(tc.name, "render")
require.NoError(t, err)
assert.Equal(t, expected, got)
}
}
// IPv6
{
tc.opts.IPFamily = egv1a1.IPv6
gotIPv6, err := GetRenderedBootstrapConfig(tc.opts)
require.NoError(t, err)

expected, err := readTestData(tc.name)
require.NoError(t, err)
assert.Equal(t, expected, got)
if *overrideTestData {
// nolint:gosec
err = os.WriteFile(path.Join("testdata", "ipv6", fmt.Sprintf("%s.yaml", tc.name)), []byte(gotIPv6), 0o644)
require.NoError(t, err)
} else {
expected, err := readTestData(tc.name, "ipv6")
require.NoError(t, err)
assert.Equal(t, expected, gotIPv6)
}
}
})
}
}

func readTestData(caseName string) (string, error) {
filename := path.Join("testdata", "render", fmt.Sprintf("%s.yaml", caseName))

func readTestData(caseName string, sub string) (string, error) {
filename := path.Join("testdata", sub, fmt.Sprintf("%s.yaml", caseName))
b, err := os.ReadFile(filename)
if err != nil {
return "", err
Expand Down
168 changes: 168 additions & 0 deletions internal/xds/bootstrap/testdata/ipv6/custom-server-port.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
admin:
access_log:
- name: envoy.access_loggers.file
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: /dev/null
address:
socket_address:
address: ::1
port_value: 2222
layered_runtime:
layers:
- name: global_config
static_layer:
envoy.restart_features.use_eds_cache_for_ads: true
re2.max_program_size.error_level: 4294967295
re2.max_program_size.warn_level: 1000
dynamic_resources:
ads_config:
api_type: DELTA_GRPC
transport_api_version: V3
grpc_services:
- envoy_grpc:
cluster_name: xds_cluster
set_node_on_first_message_only: true
lds_config:
ads: {}
resource_api_version: V3
cds_config:
ads: {}
resource_api_version: V3
static_resources:
listeners:
- name: envoy-gateway-proxy-ready-::-3333
address:
socket_address:
address: '::'
port_value: 3333
protocol: TCP
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: eg-ready-http
route_config:
name: local_route
virtual_hosts:
- name: prometheus_stats
domains:
- "*"
routes:
- match:
prefix: /stats/prometheus
route:
cluster: prometheus_stats
http_filters:
- name: envoy.filters.http.health_check
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.health_check.v3.HealthCheck
pass_through_mode: false
headers:
- name: ":path"
string_match:
exact: /ready
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
clusters:
- name: prometheus_stats
connect_timeout: 0.250s
type: STATIC
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: prometheus_stats
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: ::1
port_value: 2222
- connect_timeout: 10s
load_assignment:
cluster_name: xds_cluster
endpoints:
- load_balancing_weight: 1
lb_endpoints:
- load_balancing_weight: 1
endpoint:
address:
socket_address:
address: foo.bar
port_value: 12345
typed_extension_protocol_options:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
"@type": "type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions"
explicit_http_config:
http2_protocol_options:
connection_keepalive:
interval: 30s
timeout: 5s
name: xds_cluster
type: STRICT_DNS
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
common_tls_context:
tls_params:
tls_maximum_protocol_version: TLSv1_3
tls_certificate_sds_secret_configs:
- name: xds_certificate
sds_config:
path_config_source:
path: /sds/xds-certificate.json
resource_api_version: V3
validation_context_sds_secret_config:
name: xds_trusted_ca
sds_config:
path_config_source:
path: /sds/xds-trusted-ca.json
resource_api_version: V3
- name: wasm_cluster
type: STRICT_DNS
connect_timeout: 10s
load_assignment:
cluster_name: wasm_cluster
endpoints:
- load_balancing_weight: 1
lb_endpoints:
- load_balancing_weight: 1
endpoint:
address:
socket_address:
address: envoy-gateway
port_value: 1111
typed_extension_protocol_options:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
"@type": "type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions"
explicit_http_config:
http2_protocol_options: {}
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
common_tls_context:
tls_params:
tls_maximum_protocol_version: TLSv1_3
tls_certificate_sds_secret_configs:
- name: xds_certificate
sds_config:
path_config_source:
path: /sds/xds-certificate.json
resource_api_version: V3
validation_context_sds_secret_config:
name: xds_trusted_ca
sds_config:
path_config_source:
path: /sds/xds-trusted-ca.json
resource_api_version: V3
overload_manager:
refresh_interval: 0.25s
resource_monitors:
- name: "envoy.resource_monitors.global_downstream_max_connections"
typed_config:
"@type": type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
max_active_downstream_connections: 50000
Loading

0 comments on commit fa1d082

Please sign in to comment.