Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion test/envoye2e/driver/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down
32 changes: 30 additions & 2 deletions test/envoye2e/driver/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
}
}
111 changes: 37 additions & 74 deletions test/envoye2e/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}...)
}
Loading