@@ -27,7 +27,6 @@ import (
27
27
"github.com/google/go-cmp/cmp"
28
28
_ "google.golang.org/grpc/balancer/roundrobin"
29
29
"google.golang.org/grpc/internal/balancer/stub"
30
- "google.golang.org/grpc/internal/envconfig"
31
30
"google.golang.org/grpc/internal/grpctest"
32
31
"google.golang.org/grpc/internal/pretty"
33
32
internalserviceconfig "google.golang.org/grpc/internal/serviceconfig"
@@ -45,6 +44,7 @@ import (
45
44
v3clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
46
45
v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
47
46
v3leastrequestpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/least_request/v3"
47
+ v3maglevpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/maglev/v3"
48
48
v3pickfirstpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/pick_first/v3"
49
49
v3ringhashpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/ring_hash/v3"
50
50
v3roundrobinpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/round_robin/v3"
@@ -69,17 +69,13 @@ func wrrLocalityBalancerConfig(childPolicy *internalserviceconfig.BalancerConfig
69
69
}
70
70
71
71
func (s ) TestConvertToServiceConfigSuccess (t * testing.T ) {
72
- defer func (old bool ) { envconfig .LeastRequestLB = old }(envconfig .LeastRequestLB )
73
- envconfig .LeastRequestLB = false
74
-
75
72
const customLBPolicyName = "myorg.MyCustomLeastRequestPolicy"
76
73
stub .Register (customLBPolicyName , stub.BalancerFuncs {})
77
74
78
75
tests := []struct {
79
76
name string
80
77
policy * v3clusterpb.LoadBalancingPolicy
81
78
wantConfig string // JSON config
82
- lrEnabled bool
83
79
}{
84
80
{
85
81
name : "ring_hash" ,
@@ -112,7 +108,6 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) {
112
108
},
113
109
},
114
110
wantConfig : `[{"least_request_experimental": { "choiceCount": 3 }}]` ,
115
- lrEnabled : true ,
116
111
},
117
112
{
118
113
name : "pick_first_shuffle" ,
@@ -197,26 +192,6 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) {
197
192
},
198
193
wantConfig : `[{"pick_first": { "shuffleAddressList": true }}]` ,
199
194
},
200
- {
201
- name : "least_request_disabled_pf_rr_use_first_supported" ,
202
- policy : & v3clusterpb.LoadBalancingPolicy {
203
- Policies : []* v3clusterpb.LoadBalancingPolicy_Policy {
204
- {
205
- TypedExtensionConfig : & v3corepb.TypedExtensionConfig {
206
- TypedConfig : testutils .MarshalAny (t , & v3leastrequestpb.LeastRequest {
207
- ChoiceCount : wrapperspb .UInt32 (32 ),
208
- }),
209
- },
210
- },
211
- {
212
- TypedExtensionConfig : & v3corepb.TypedExtensionConfig {
213
- TypedConfig : testutils .MarshalAny (t , & v3roundrobinpb.RoundRobin {}),
214
- },
215
- },
216
- },
217
- },
218
- wantConfig : `[{"round_robin": {}}]` ,
219
- },
220
195
{
221
196
name : "custom_lb_type_v3_struct" ,
222
197
policy : & v3clusterpb.LoadBalancingPolicy {
@@ -307,10 +282,6 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) {
307
282
308
283
for _ , test := range tests {
309
284
t .Run (test .name , func (t * testing.T ) {
310
- if test .lrEnabled {
311
- defer func (old bool ) { envconfig .LeastRequestLB = old }(envconfig .LeastRequestLB )
312
- envconfig .LeastRequestLB = true
313
- }
314
285
rawJSON , err := xdslbregistry .ConvertToServiceConfig (test .policy , 0 )
315
286
if err != nil {
316
287
t .Fatalf ("ConvertToServiceConfig(%s) failed: %v" , pretty .ToJSON (test .policy ), err )
@@ -381,8 +352,8 @@ func (s) TestConvertToServiceConfigFailure(t *testing.T) {
381
352
},
382
353
{
383
354
TypedExtensionConfig : & v3corepb.TypedExtensionConfig {
384
- // Not supported by gRPC-Go .
385
- TypedConfig : testutils .MarshalAny (t , & v3leastrequestpb. LeastRequest {}),
355
+ // Maglev is not yet supported by gRPC.
356
+ TypedConfig : testutils .MarshalAny (t , & v3maglevpb. Maglev {}),
386
357
},
387
358
},
388
359
},
0 commit comments