diff --git a/test/envoye2e/driver/stats.go b/test/envoye2e/driver/stats.go index e6203b1b93e..0b6110d59a8 100644 --- a/test/envoye2e/driver/stats.go +++ b/test/envoye2e/driver/stats.go @@ -21,6 +21,7 @@ import ( "time" "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" dto "github.com/prometheus/client_model/go" "github.com/prometheus/common/expfmt" "google.golang.org/protobuf/testing/protocmp" @@ -61,7 +62,7 @@ func (s *Stats) Run(p *Params) error { log.Printf("matched metric %q", metric.GetName()) count++ continue - } else if _, ok := matcher.(*MissingStat); ok && err != nil { + } else if _, ok := matcher.(*MissingStat); ok { return fmt.Errorf("found metric that should have been missing: %s", metric.GetName()) } log.Printf("metric %q did not match: %v\n", metric.GetName(), err) @@ -101,6 +102,28 @@ func (me *ExactStat) Matches(params *Params, that *dto.MetricFamily) error { var _ StatMatcher = &ExactStat{} +// ExistStat matches if the metric exists in the output, +// but does not compare the Counter. +type ExistStat struct { + Metric string +} + +func (me *ExistStat) Matches(params *Params, that *dto.MetricFamily) error { + metric := &dto.MetricFamily{} + params.LoadTestProto(me.Metric, metric) + + switch metric.Type { + case dto.MetricType_COUNTER.Enum(): + if diff := cmp.Diff(metric, that, protocmp.Transform(), cmpopts.IgnoreFields(dto.Counter{}, "value")); diff != "" { + return fmt.Errorf("diff: %v, got: %v, want: %v", diff, that, metric) + } + } + + return nil +} + +var _ StatMatcher = &ExistStat{} + type PartialStat struct { Metric string } diff --git a/test/envoye2e/driver/tcp.go b/test/envoye2e/driver/tcp.go index 63b071971e7..c8405aa65c6 100644 --- a/test/envoye2e/driver/tcp.go +++ b/test/envoye2e/driver/tcp.go @@ -34,7 +34,7 @@ var _ Step = &TCPServer{} func (t *TCPServer) Run(p *Params) error { var err error - t.lis, err = net.Listen("tcp", fmt.Sprintf(":%d", p.Ports.BackendPort)) + t.lis, err = net.Listen("tcp", fmt.Sprintf("127.0.0.3:%d", p.Ports.BackendPort)) if err != nil { return fmt.Errorf("failed to listen on %v", err) } @@ -65,7 +65,7 @@ func waitForTCPServer(port uint16) error { for i := 0; i < 30; i++ { var conn net.Conn var err error - conn, err = net.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", port)) + conn, err = net.Dial("tcp", fmt.Sprintf("127.0.0.3:%d", port)) if err != nil { log.Println("Will wait 200ms and try again.") time.Sleep(200 * time.Millisecond) @@ -221,3 +221,31 @@ func (t *InterceptedTCPConnection) Run(p *Params) error { } func (t *InterceptedTCPConnection) Cleanup() {} + +type TCPLoad struct { + conn *net.Conn +} + +var _ Step = &TCPLoad{} + +func (t *TCPLoad) Run(p *Params) error { + conn, err := net.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", p.Ports.ClientPort)) + if err != nil { + return fmt.Errorf("failed to connect to tcp server: %v", err) + } + t.conn = &conn + + go func() { + for { + fmt.Fprintf(conn, "ping\n") + time.Sleep(1 * time.Second) + } + }() + return nil +} + +func (t *TCPLoad) Cleanup() { + if t.conn != nil { + (*t.conn).Close() + } +} diff --git a/test/envoye2e/inventory.go b/test/envoye2e/inventory.go index 75ad0faf68c..27542d889a5 100644 --- a/test/envoye2e/inventory.go +++ b/test/envoye2e/inventory.go @@ -18,80 +18,43 @@ import ( "istio.io/proxy/test/envoye2e/env" ) -var ProxyE2ETests *env.TestInventory +var ProxyE2ETests = &env.TestInventory{} func init() { - // TODO(bianpengyuan): automatically generate this. - ProxyE2ETests = &env.TestInventory{ - Tests: []string{ - "TestAttributeGen", - "TestBasicFlow", - "TestBasicHTTP", - "TestBasicHTTPGateway", - "TestBasicHTTPwithTLS", - "TestBasicTCPFlow", - "TestBasicCONNECT/quic", - "TestBasicCONNECT/h2", - "TestPassthroughCONNECT/quic", - "TestPassthroughCONNECT/h2", - "TestHTTPExchange", - "TestNativeHTTPExchange", - "TestHTTPLocalRatelimit", - "TestStackdriverAccessLog/AllClientErrorRequestsGetsLoggedOnNoMxAndError", - "TestStackdriverAccessLog/AllErrorRequestsGetsLogged", - "TestStackdriverAccessLog/NoClientRequestsGetsLoggedOnErrorConfigAndAllSuccessRequests", - "TestStackdriverAccessLog/RequestGetsLoggedAgain", - "TestStackdriverAccessLog/StackdriverAndAccessLogPlugin", - "TestStackdriverAccessLogFilter", - "TestStackdriverAttributeGen", - "TestStackdriverAuditLog", - "TestStackdriverCustomAccessLog", - "TestStackdriverGCEInstances", - "TestStackdriverGenericNode", - "TestStackdriverMetricExpiry", - "TestStackdriverParallel", - "TestStackdriverPayload", - "TestStackdriverPayloadGateway", - "TestStackdriverPayloadUtf8", - "TestStackdriverPayloadWithTLS", - "TestStackdriverRbacAccessDenied/ActionAllow", - "TestStackdriverRbacAccessDenied/ActionBoth", - "TestStackdriverRbacAccessDenied/ActionDeny", - "TestStackdriverRbacTCPDryRun", - "TestStackdriverRbacTCPDryRun/BaseCase", - "TestStackdriverRbacTCPDryRun/NoAlpn", - "TestStackdriverReload", - "TestStackdriverTCPMetadataExchange/BaseCase", - "TestStackdriverTCPMetadataExchange/NoAlpn", - "TestStackdriverVMReload", - "TestStats403Failure/envoy.wasm.runtime.v8", - "TestStats403Failure/#00", - "TestStatsECDS/envoy.wasm.runtime.v8", - "TestStatsECDS/#00", - "TestStatsEndpointLabels/envoy.wasm.runtime.v8", - "TestStatsEndpointLabels/#00", - "TestStatsServerWaypointProxy", - "TestStatsServerWaypointProxyCONNECT", - "TestStatsGrpc/envoy.wasm.runtime.v8", - "TestStatsGrpc/#00", - "TestStatsGrpcStream/envoy.wasm.runtime.v8", - "TestStatsGrpcStream/#00", - "TestStatsParallel/Default", - "TestStatsParallel/Customized", - "TestStatsPayload/Customized/envoy.wasm.runtime.v8", - "TestStatsPayload/Customized/", - "TestStatsPayload/Default/envoy.wasm.runtime.v8", - "TestStatsPayload/Default/", - "TestStatsPayload/DisableHostHeader/envoy.wasm.runtime.v8", - "TestStatsPayload/DisableHostHeader/", - "TestStatsPayload/UseHostHeader/envoy.wasm.runtime.v8", - "TestStatsPayload/UseHostHeader/", - "TestStatsParserRegression", - "TestStatsExpiry", - "TestTCPMetadataExchange", - "TestTCPMetadataExchangeNoAlpn", - "TestTCPMetadataExchangeWithConnectionTermination", - "TestOtelPayload", - }, - } + ProxyE2ETests.Tests = append(ProxyE2ETests.Tests, []string{ + "TestAttributeGen", + "TestBasicFlow", + "TestBasicHTTP", + "TestBasicHTTPGateway", + "TestBasicHTTPwithTLS", + "TestBasicTCPFlow", + "TestBasicCONNECT/quic", + "TestBasicCONNECT/h2", + "TestPassthroughCONNECT/quic", + "TestPassthroughCONNECT/h2", + "TestHTTPExchange", + "TestNativeHTTPExchange", + "TestHTTPLocalRatelimit", + "TestStats403Failure/#00", + "TestStatsECDS/#00", + "TestStatsEndpointLabels/#00", + "TestStatsServerWaypointProxy", + "TestStatsServerWaypointProxyCONNECT", + "TestStatsGrpc/#00", + "TestStatsGrpcStream/#00", + "TestStatsParallel/Default", + "TestStatsParallel/Customized", + "TestStatsPayload/Customized/", + "TestStatsPayload/Default/", + "TestStatsPayload/DisableHostHeader/", + "TestStatsPayload/UseHostHeader/", + "TestStatsParserRegression", + "TestStatsExpiry", + "TestTCPMetadataExchange/false", + "TestTCPMetadataExchange/true", + "TestTCPMetadataExchangeNoAlpn", + "TestTCPMetadataExchangeWithConnectionTermination", + "TestOtelPayload", + "TestTCPMetadataNotFoundReporting", + }...) } diff --git a/test/envoye2e/tcp_metadata_exchange/tcp_metadata_exchange_test.go b/test/envoye2e/tcp_metadata_exchange/tcp_metadata_exchange_test.go index 82ad0e31901..7d458995e83 100644 --- a/test/envoye2e/tcp_metadata_exchange/tcp_metadata_exchange_test.go +++ b/test/envoye2e/tcp_metadata_exchange/tcp_metadata_exchange_test.go @@ -15,6 +15,7 @@ package client_test import ( + "fmt" "testing" "time" @@ -23,9 +24,103 @@ import ( ) func TestTCPMetadataExchange(t *testing.T) { + for _, wds := range []bool{true, false} { + t.Run(fmt.Sprintf("%t", wds), func(t *testing.T) { + params := driver.NewTestParams(t, map[string]string{ + "DisableDirectResponse": "true", + "StatsConfig": driver.LoadTestData("testdata/bootstrap/stats.yaml.tmpl"), + }, envoye2e.ProxyE2ETests) + mxStats := map[string]driver.StatMatcher{ + "envoy_metadata_exchange_metadata_added": &driver.ExactStat{Metric: "testdata/metric/tcp_server_mx_stats_metadata_added.yaml.tmpl"}, + } + if wds { + params.Vars["AlpnProtocol"] = "disabled" + params.Vars["EnableMetadataDiscovery"] = "true" + params.Vars["AppVersionFallback"] = "true" + mxStats["envoy_metadata_exchange_alpn_protocol_not_found"] = &driver.ExactStat{Metric: "testdata/metric/tcp_server_mx_stats_alpn_not_found.yaml.tmpl"} + } else { + params.Vars["AlpnProtocol"] = "mx-protocol" + mxStats["envoy_metadata_exchange_alpn_protocol_found"] = &driver.ExactStat{Metric: "testdata/metric/tcp_server_mx_stats_alpn_found.yaml.tmpl"} + } + params.Vars["ClientMetadata"] = params.LoadTestData("testdata/client_node_metadata.json.tmpl") + params.Vars["ServerMetadata"] = params.LoadTestData("testdata/server_node_metadata.json.tmpl") + params.Vars["ServerNetworkFilters"] = params.LoadTestData("testdata/filters/server_mx_network_filter.yaml.tmpl") + "\n" + + params.LoadTestData("testdata/filters/server_stats_network_filter.yaml.tmpl") + params.Vars["ClientUpstreamFilters"] = params.LoadTestData("testdata/filters/client_mx_network_filter.yaml.tmpl") + params.Vars["ClientNetworkFilters"] = params.LoadTestData("testdata/filters/client_stats_network_filter.yaml.tmpl") + params.Vars["ClientClusterTLSContext"] = params.LoadTestData("testdata/transport_socket/client.yaml.tmpl") + params.Vars["ServerListenerTLSContext"] = params.LoadTestData("testdata/transport_socket/server.yaml.tmpl") + + if err := (&driver.Scenario{ + Steps: []driver.Step{ + &driver.XDS{}, + &driver.Update{ + Node: "client", + Version: "0", + Clusters: []string{params.LoadTestData("testdata/cluster/tcp_client.yaml.tmpl")}, + Listeners: []string{params.LoadTestData("testdata/listener/tcp_client.yaml.tmpl")}, + }, + &driver.Update{ + Node: "server", + Version: "0", + Clusters: []string{params.LoadTestData("testdata/cluster/tcp_server.yaml.tmpl")}, + Listeners: []string{params.LoadTestData("testdata/listener/tcp_server.yaml.tmpl")}, + }, + &driver.UpdateWorkloadMetadata{Workloads: []driver.WorkloadMetadata{{ + Address: "127.0.0.1", + Metadata: ` +namespace: default +workload_name: productpage-v1 +workload_type: DEPLOYMENT +canonical_name: productpage-v1 +canonical_revision: version-1 +cluster_id: client-cluster +uid: //v1/pod/default/productpage +`}, { + Address: "127.0.0.2", + Metadata: ` +namespace: default +workload_name: ratings-v1 +workload_type: DEPLOYMENT +canonical_name: ratings +canonical_revision: version-1 +cluster_id: server-cluster +uid: //v1/pod/default/ratings +`}, + }}, + &driver.Envoy{Bootstrap: params.LoadTestData("testdata/bootstrap/client.yaml.tmpl")}, + &driver.Envoy{Bootstrap: params.LoadTestData("testdata/bootstrap/server.yaml.tmpl")}, + &driver.Sleep{Duration: 1 * time.Second}, + &driver.TCPServer{Prefix: "hello"}, + &driver.Repeat{ + N: 10, + Step: &driver.TCPConnection{}, + }, + &driver.Stats{AdminPort: params.Ports.ClientAdmin, Matchers: map[string]driver.StatMatcher{ + "istio_tcp_connections_closed_total": &driver.ExactStat{Metric: "testdata/metric/tcp_client_connection_close.yaml.tmpl"}, + "istio_tcp_connections_opened_total": &driver.ExactStat{Metric: "testdata/metric/tcp_client_connection_open.yaml.tmpl"}, + "istio_tcp_received_bytes_total": &driver.ExactStat{Metric: "testdata/metric/tcp_client_received_bytes.yaml.tmpl"}, + "istio_tcp_sent_bytes_total": &driver.ExactStat{Metric: "testdata/metric/tcp_client_sent_bytes.yaml.tmpl"}, + }}, + &driver.Stats{AdminPort: params.Ports.ServerAdmin, Matchers: map[string]driver.StatMatcher{ + "istio_tcp_connections_closed_total": &driver.ExactStat{Metric: "testdata/metric/tcp_server_connection_close.yaml.tmpl"}, + "istio_tcp_connections_opened_total": &driver.ExactStat{Metric: "testdata/metric/tcp_server_connection_open.yaml.tmpl"}, + "istio_tcp_received_bytes_total": &driver.ExactStat{Metric: "testdata/metric/tcp_server_received_bytes.yaml.tmpl"}, + "istio_tcp_sent_bytes_total": &driver.ExactStat{Metric: "testdata/metric/tcp_server_sent_bytes.yaml.tmpl"}, + }}, + &driver.Stats{AdminPort: params.Ports.ServerAdmin, Matchers: mxStats}, + }, + }).Run(params); err != nil { + t.Fatal(err) + } + }) + } +} + +func TestTCPMetadataExchangeNoAlpn(t *testing.T) { params := driver.NewTestParams(t, map[string]string{ "DisableDirectResponse": "true", - "AlpnProtocol": "mx-protocol", + "AlpnProtocol": "some-protocol", "StatsConfig": driver.LoadTestData("testdata/bootstrap/stats.yaml.tmpl"), }, envoye2e.ProxyE2ETests) params.Vars["ClientMetadata"] = params.LoadTestData("testdata/client_node_metadata.json.tmpl") @@ -60,19 +155,9 @@ func TestTCPMetadataExchange(t *testing.T) { N: 10, Step: &driver.TCPConnection{}, }, - &driver.Stats{AdminPort: params.Ports.ClientAdmin, Matchers: map[string]driver.StatMatcher{ - "istio_tcp_connections_closed_total": &driver.ExactStat{Metric: "testdata/metric/tcp_client_connection_close.yaml.tmpl"}, - "istio_tcp_connections_opened_total": &driver.ExactStat{Metric: "testdata/metric/tcp_client_connection_open.yaml.tmpl"}, - "istio_tcp_received_bytes_total": &driver.ExactStat{Metric: "testdata/metric/tcp_client_received_bytes.yaml.tmpl"}, - "istio_tcp_sent_bytes_total": &driver.ExactStat{Metric: "testdata/metric/tcp_client_sent_bytes.yaml.tmpl"}, - }}, &driver.Stats{AdminPort: params.Ports.ServerAdmin, Matchers: map[string]driver.StatMatcher{ - "istio_tcp_connections_closed_total": &driver.ExactStat{Metric: "testdata/metric/tcp_server_connection_close.yaml.tmpl"}, - "istio_tcp_connections_opened_total": &driver.ExactStat{Metric: "testdata/metric/tcp_server_connection_open.yaml.tmpl"}, - "istio_tcp_received_bytes_total": &driver.ExactStat{Metric: "testdata/metric/tcp_server_received_bytes.yaml.tmpl"}, - "istio_tcp_sent_bytes_total": &driver.ExactStat{Metric: "testdata/metric/tcp_server_sent_bytes.yaml.tmpl"}, - "envoy_metadata_exchange_alpn_protocol_found": &driver.ExactStat{Metric: "testdata/metric/tcp_server_mx_stats_alpn_found.yaml.tmpl"}, - "envoy_metadata_exchange_metadata_added": &driver.ExactStat{Metric: "testdata/metric/tcp_server_mx_stats_metadata_added.yaml.tmpl"}, + "istio_tcp_connections_opened_total": &driver.ExactStat{Metric: "testdata/metric/tcp_server_connection_open_without_mx.yaml.tmpl"}, + "envoy_metadata_exchange_alpn_protocol_not_found": &driver.ExactStat{Metric: "testdata/metric/tcp_server_mx_stats_alpn_not_found.yaml.tmpl"}, }}, }, }).Run(params); err != nil { @@ -80,18 +165,18 @@ func TestTCPMetadataExchange(t *testing.T) { } } -func TestTCPMetadataExchangeNoAlpn(t *testing.T) { +func TestTCPMetadataExchangeWithConnectionTermination(t *testing.T) { params := driver.NewTestParams(t, map[string]string{ "DisableDirectResponse": "true", - "AlpnProtocol": "some-protocol", + "AlpnProtocol": "mx-protocol", "StatsConfig": driver.LoadTestData("testdata/bootstrap/stats.yaml.tmpl"), }, envoye2e.ProxyE2ETests) params.Vars["ClientMetadata"] = params.LoadTestData("testdata/client_node_metadata.json.tmpl") params.Vars["ServerMetadata"] = params.LoadTestData("testdata/server_node_metadata.json.tmpl") - params.Vars["ServerNetworkFilters"] = params.LoadTestData("testdata/filters/server_mx_network_filter.yaml.tmpl") + "\n" + - params.LoadTestData("testdata/filters/server_stats_network_filter.yaml.tmpl") + params.Vars["ServerNetworkFilters"] = params.LoadTestData("testdata/filters/server_stats_network_filter.yaml.tmpl") params.Vars["ClientUpstreamFilters"] = params.LoadTestData("testdata/filters/client_mx_network_filter.yaml.tmpl") - params.Vars["ClientNetworkFilters"] = params.LoadTestData("testdata/filters/client_stats_network_filter.yaml.tmpl") + params.Vars["ClientNetworkFilters"] = params.LoadTestData("testdata/filters/server_mx_network_filter.yaml.tmpl") + "\n" + + params.LoadTestData("testdata/filters/client_stats_network_filter.yaml.tmpl") params.Vars["ClientClusterTLSContext"] = params.LoadTestData("testdata/transport_socket/client.yaml.tmpl") params.Vars["ServerListenerTLSContext"] = params.LoadTestData("testdata/transport_socket/server.yaml.tmpl") @@ -113,14 +198,15 @@ func TestTCPMetadataExchangeNoAlpn(t *testing.T) { &driver.Envoy{Bootstrap: params.LoadTestData("testdata/bootstrap/client.yaml.tmpl")}, &driver.Envoy{Bootstrap: params.LoadTestData("testdata/bootstrap/server.yaml.tmpl")}, &driver.Sleep{Duration: 1 * time.Second}, - &driver.TCPServer{Prefix: "hello"}, + &driver.TCPServerAcceptAndClose{}, &driver.Repeat{ - N: 10, - Step: &driver.TCPConnection{}, + N: 10, + Step: &driver.InterceptedTCPConnection{ + ReadTimeout: 10 * time.Second, + }, }, &driver.Stats{AdminPort: params.Ports.ServerAdmin, Matchers: map[string]driver.StatMatcher{ - "istio_tcp_connections_opened_total": &driver.ExactStat{Metric: "testdata/metric/tcp_server_connection_open_without_mx.yaml.tmpl"}, - "envoy_metadata_exchange_alpn_protocol_not_found": &driver.ExactStat{Metric: "testdata/metric/tcp_server_mx_stats_alpn_not_found.yaml.tmpl"}, + "istio_tcp_connections_opened_total": &driver.ExactStat{Metric: "testdata/metric/tcp_server_connection_open_without_mx.yaml.tmpl"}, }}, }, }).Run(params); err != nil { @@ -128,20 +214,16 @@ func TestTCPMetadataExchangeNoAlpn(t *testing.T) { } } -func TestTCPMetadataExchangeWithConnectionTermination(t *testing.T) { +func TestTCPMetadataNotFoundReporting(t *testing.T) { params := driver.NewTestParams(t, map[string]string{ "DisableDirectResponse": "true", "AlpnProtocol": "mx-protocol", "StatsConfig": driver.LoadTestData("testdata/bootstrap/stats.yaml.tmpl"), }, envoye2e.ProxyE2ETests) + params.Vars["ClientMetadata"] = params.LoadTestData("testdata/client_node_metadata.json.tmpl") - params.Vars["ServerMetadata"] = params.LoadTestData("testdata/server_node_metadata.json.tmpl") - params.Vars["ServerNetworkFilters"] = params.LoadTestData("testdata/filters/server_stats_network_filter.yaml.tmpl") params.Vars["ClientUpstreamFilters"] = params.LoadTestData("testdata/filters/client_mx_network_filter.yaml.tmpl") - params.Vars["ClientNetworkFilters"] = params.LoadTestData("testdata/filters/server_mx_network_filter.yaml.tmpl") + "\n" + - params.LoadTestData("testdata/filters/client_stats_network_filter.yaml.tmpl") - params.Vars["ClientClusterTLSContext"] = params.LoadTestData("testdata/transport_socket/client.yaml.tmpl") - params.Vars["ServerListenerTLSContext"] = params.LoadTestData("testdata/transport_socket/server.yaml.tmpl") + params.Vars["ClientNetworkFilters"] = params.LoadTestData("testdata/filters/client_stats_network_filter.yaml.tmpl") if err := (&driver.Scenario{ Steps: []driver.Step{ @@ -149,27 +231,30 @@ func TestTCPMetadataExchangeWithConnectionTermination(t *testing.T) { &driver.Update{ Node: "client", Version: "0", - Clusters: []string{params.LoadTestData("testdata/cluster/tcp_client.yaml.tmpl")}, + Clusters: []string{params.LoadTestData("testdata/cluster/tcp_client_unknown.yaml.tmpl")}, Listeners: []string{params.LoadTestData("testdata/listener/tcp_client.yaml.tmpl")}, }, - &driver.Update{ - Node: "server", - Version: "0", - Clusters: []string{params.LoadTestData("testdata/cluster/tcp_server.yaml.tmpl")}, - Listeners: []string{params.LoadTestData("testdata/listener/tcp_server.yaml.tmpl")}, - }, + &driver.UpdateWorkloadMetadata{Workloads: []driver.WorkloadMetadata{{ + Address: "127.0.0.1", + Metadata: ` +namespace: default +workload_name: productpage-v1 +workload_type: DEPLOYMENT +canonical_name: productpage-v1 +canonical_revision: version-1 +cluster_id: client-cluster +uid: //v1/pod/default/productpage +`}, + }}, &driver.Envoy{Bootstrap: params.LoadTestData("testdata/bootstrap/client.yaml.tmpl")}, - &driver.Envoy{Bootstrap: params.LoadTestData("testdata/bootstrap/server.yaml.tmpl")}, &driver.Sleep{Duration: 1 * time.Second}, - &driver.TCPServerAcceptAndClose{}, + &driver.TCPServer{}, &driver.Repeat{ - N: 10, - Step: &driver.InterceptedTCPConnection{ - ReadTimeout: 10 * time.Second, - }, + N: 1, + Step: &driver.TCPLoad{}, }, - &driver.Stats{AdminPort: params.Ports.ServerAdmin, Matchers: map[string]driver.StatMatcher{ - "istio_tcp_connections_opened_total": &driver.ExactStat{Metric: "testdata/metric/tcp_server_connection_open_without_mx.yaml.tmpl"}, + &driver.Stats{AdminPort: params.Ports.ClientAdmin, Matchers: map[string]driver.StatMatcher{ + "istio_tcp_sent_bytes_total": &driver.ExistStat{Metric: "testdata/metric/tcp_client_sent_bytes_unknown.yaml.tmpl"}, }}, }, }).Run(params); err != nil { diff --git a/testdata/cluster/tcp_client_unknown.yaml.tmpl b/testdata/cluster/tcp_client_unknown.yaml.tmpl new file mode 100644 index 00000000000..a7ecdd3025b --- /dev/null +++ b/testdata/cluster/tcp_client_unknown.yaml.tmpl @@ -0,0 +1,22 @@ +name: outbound|9080|tcp|server.default.svc.cluster.local +metadata: + filter_metadata: + istio: + services: + - host: server.default.svc.cluster.local + name: server + namespace: default +connect_timeout: 5s +type: STATIC +load_assignment: + cluster_name: outbound|9080|tcp|server.default.svc.cluster.local + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 127.0.0.3 + port_value: {{ .Ports.BackendPort }} +{{ .Vars.ClientClusterTLSContext }} +filters: +{{ .Vars.ClientUpstreamFilters | fill }} diff --git a/testdata/metric/tcp_client_sent_bytes_unknown.yaml.tmpl b/testdata/metric/tcp_client_sent_bytes_unknown.yaml.tmpl new file mode 100644 index 00000000000..b8ef83874c2 --- /dev/null +++ b/testdata/metric/tcp_client_sent_bytes_unknown.yaml.tmpl @@ -0,0 +1,57 @@ +name: istio_tcp_sent_bytes_total +type: COUNTER +metric: +- counter: + value: 0 + label: + - name: reporter + value: source + - name: source_workload + value: productpage-v1 + - name: source_canonical_service + value: productpage-v1 + - name: source_canonical_revision + value: version-1 + - name: source_workload_namespace + value: default + - name: source_principal + value: unknown + - name: source_app + value: productpage + - name: source_version + value: v1 + - name: source_cluster + value: client-cluster + - name: destination_workload + value: unknown + - name: destination_workload_namespace + value: unknown + - name: destination_principal + value: unknown + - name: destination_app + value: unknown +{{- if eq .Vars.AppVersionFallback "true" }} + - name: destination_version + value: version-1 +{{- else }} + - name: destination_version + value: unknown +{{- end }} + - name: destination_service + value: server.default.svc.cluster.local + - name: destination_canonical_service + value: unknown + - name: destination_canonical_revision + value: latest + - name: destination_service_name + value: server + - name: destination_service_namespace + value: unknown + - name: destination_cluster + value: unknown + - name: request_protocol + value: tcp + - name: response_flags + value: "-" + - name: connection_security_policy + value: unknown