Skip to content

Commit

Permalink
Add xDS e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
zasweq committed Aug 12, 2023
1 parent 6940839 commit 8684203
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 174 deletions.
2 changes: 1 addition & 1 deletion balancer/leastrequest/leastrequest.go
Expand Up @@ -31,7 +31,7 @@ import (
"google.golang.org/grpc/serviceconfig"
)

// Global to stub out in tests.
// grpcranduint32 is a global to stub out in tests.
var grpcranduint32 = grpcrand.Uint32

// Name is the name of the least request balancer.
Expand Down
95 changes: 0 additions & 95 deletions internal/balancer/leastrequest/balancer_test.go

This file was deleted.

75 changes: 0 additions & 75 deletions internal/balancer/leastrequest/leastrequest.go

This file was deleted.

28 changes: 27 additions & 1 deletion test/xds/xds_client_custom_lb_test.go
Expand Up @@ -25,6 +25,7 @@ import (
"time"

"google.golang.org/grpc"
_ "google.golang.org/grpc/balancer/leastrequest" // To register least_request
_ "google.golang.org/grpc/balancer/weightedroundrobin" // To register weighted_round_robin
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/internal/envconfig"
Expand All @@ -41,6 +42,7 @@ import (
v3listenerpb "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
v3routepb "github.com/envoyproxy/go-control-plane/envoy/config/route/v3"
v3clientsideweightedroundrobinpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3"
v3leastrequestpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/least_request/v3"
v3roundrobinpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/round_robin/v3"
v3wrrlocalitypb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/wrr_locality/v3"
"github.com/golang/protobuf/proto"
Expand Down Expand Up @@ -96,6 +98,11 @@ func (s) TestWrrLocality(t *testing.T) {
defer func() {
envconfig.XDSCustomLBPolicy = oldCustomLBSupport
}()
oldLeastRequestLBSupport := envconfig.LeastRequestLB
envconfig.LeastRequestLB = true
defer func() {
envconfig.LeastRequestLB = oldLeastRequestLBSupport
}()

backend1 := stubserver.StartTestService(t, nil)
port1 := testutils.ParsePort(t, backend1.Address)
Expand Down Expand Up @@ -194,12 +201,31 @@ func (s) TestWrrLocality(t *testing.T) {
{addr: backend5.Address, count: 8},
},
},
{
name: "custom_lb_least_request",
wrrLocalityConfiguration: wrrLocality(&v3leastrequestpb.LeastRequest{
ChoiceCount: wrapperspb.UInt32(2),
}),
// Least request's randomness of indexes to sample (unary RPCs which
// don't persist so never any actual RPC counts over iterations)
// converges onto a round robin distribution per locality. Thus,
// expect the same distribution as round robin above.
addressDistributionWant: []struct {
addr string
count int
}{
{addr: backend1.Address, count: 6},
{addr: backend2.Address, count: 6},
{addr: backend3.Address, count: 8},
{addr: backend4.Address, count: 8},
{addr: backend5.Address, count: 8},
},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
managementServer, nodeID, _, r, cleanup := e2e.SetupManagementServer(t, e2e.ManagementServerOptions{})
defer cleanup()

routeConfigName := "route-" + serviceName
clusterName := "cluster-" + serviceName
endpointsName := "endpoints-" + serviceName
Expand Down
1 change: 1 addition & 0 deletions xds/internal/balancer/balancer.go
Expand Up @@ -20,6 +20,7 @@
package balancer

import (
_ "google.golang.org/grpc/balancer/leastrequest" // Register the least_request_experimental balancer
_ "google.golang.org/grpc/balancer/weightedtarget" // Register the weighted_target balancer
_ "google.golang.org/grpc/xds/internal/balancer/cdsbalancer" // Register the CDS balancer
_ "google.golang.org/grpc/xds/internal/balancer/clusterimpl" // Register the xds_cluster_impl balancer
Expand Down
Expand Up @@ -30,9 +30,9 @@ import (
"github.com/golang/protobuf/proto"
"google.golang.org/grpc"
"google.golang.org/grpc/balancer"
"google.golang.org/grpc/balancer/leastrequest"
"google.golang.org/grpc/balancer/roundrobin"
"google.golang.org/grpc/balancer/weightedroundrobin"
"google.golang.org/grpc/internal/balancer/leastrequest"
"google.golang.org/grpc/internal/envconfig"
internalserviceconfig "google.golang.org/grpc/internal/serviceconfig"
"google.golang.org/grpc/xds/internal/balancer/ringhash"
Expand Down
Expand Up @@ -25,8 +25,8 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"google.golang.org/grpc/balancer/leastrequest"
_ "google.golang.org/grpc/balancer/roundrobin" // To register round_robin load balancer.
"google.golang.org/grpc/internal/balancer/leastrequest"
"google.golang.org/grpc/internal/balancer/stub"
"google.golang.org/grpc/internal/envconfig"
"google.golang.org/grpc/internal/grpctest"
Expand Down

0 comments on commit 8684203

Please sign in to comment.