Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func convertWeightedRoundRobinProtoToServiceConfig(rawProto []byte, _ int) (json
if blackoutPeriodCfg := cswrrProto.GetBlackoutPeriod(); blackoutPeriodCfg != nil {
wrrLBCfg.BlackoutPeriod = internalserviceconfig.Duration(blackoutPeriodCfg.AsDuration())
}
if weightExpirationPeriodCfg := cswrrProto.GetBlackoutPeriod(); weightExpirationPeriodCfg != nil {
if weightExpirationPeriodCfg := cswrrProto.GetWeightExpirationPeriod(); weightExpirationPeriodCfg != nil {
Comment thread
gregbarasch marked this conversation as resolved.
wrrLBCfg.WeightExpirationPeriod = internalserviceconfig.Duration(weightExpirationPeriodCfg.AsDuration())
}
if weightUpdatePeriodCfg := cswrrProto.GetWeightUpdatePeriod(); weightUpdatePeriodCfg != nil {
Expand Down
43 changes: 43 additions & 0 deletions internal/xds/xdsclient/xdslbregistry/xdslbregistry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"encoding/json"
"strings"
"testing"
"time"

"github.com/google/go-cmp/cmp"
_ "google.golang.org/grpc/balancer/roundrobin"
Expand All @@ -36,13 +37,15 @@ import (
_ "google.golang.org/grpc/xds" // Register the xDS LB Registry Converters.
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/structpb"
"google.golang.org/protobuf/types/known/wrapperspb"

v1xdsudpatypepb "github.com/cncf/xds/go/udpa/type/v1"
v3xdsxdstypepb "github.com/cncf/xds/go/xds/type/v3"
v3clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/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"
v3maglevpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/maglev/v3"
v3pickfirstpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/pick_first/v3"
Expand Down Expand Up @@ -152,6 +155,46 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) {
},
wantConfig: `[{"round_robin": {}}]`,
},
{
name: "weighted_round_robin",
policy: &v3clusterpb.LoadBalancingPolicy{
Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{
{
TypedExtensionConfig: &v3corepb.TypedExtensionConfig{
TypedConfig: testutils.MarshalAny(t, &v3clientsideweightedroundrobinpb.ClientSideWeightedRoundRobin{}),
},
},
},
},
wantConfig: `[{"weighted_round_robin": {}}]`,
},
{
name: "weighted_round_robin_populated",
policy: &v3clusterpb.LoadBalancingPolicy{
Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{
{
TypedExtensionConfig: &v3corepb.TypedExtensionConfig{
TypedConfig: testutils.MarshalAny(t, &v3clientsideweightedroundrobinpb.ClientSideWeightedRoundRobin{
EnableOobLoadReport: wrapperspb.Bool(true),
OobReportingPeriod: durationpb.New(10 * time.Second),
BlackoutPeriod: durationpb.New(5 * time.Second),
WeightExpirationPeriod: durationpb.New(3 * time.Minute),
WeightUpdatePeriod: durationpb.New(1 * time.Second),
ErrorUtilizationPenalty: wrapperspb.Float(1.5),
}),
},
},
},
},
wantConfig: `[{"weighted_round_robin": {
"enableOobLoadReport": true,
"oobReportingPeriod": "10s",
"blackoutPeriod": "5s",
"weightExpirationPeriod": "180s",
"weightUpdatePeriod": "1s",
"errorUtilizationPenalty": 1.5
}}]`,
},
{
name: "round_robin_ring_hash_use_first_supported",
policy: &v3clusterpb.LoadBalancingPolicy{
Expand Down