@@ -58,7 +58,13 @@ const (
58
58
stateStoringBalancerName = "state_storing"
59
59
)
60
60
61
- var stateStoringServiceConfig = fmt .Sprintf (`{"loadBalancingConfig": [{"%s":{}}]}` , stateStoringBalancerName )
61
+ var (
62
+ stateStoringServiceConfig = fmt .Sprintf (`{"loadBalancingConfig": [{"%s":{}}]}` , stateStoringBalancerName )
63
+ ignoreBalAttributesOpt = cmp .Transformer ("IgnoreBalancerAttributes" , func (a resolver.Address ) resolver.Address {
64
+ a .BalancerAttributes = nil
65
+ return a
66
+ })
67
+ )
62
68
63
69
type s struct {
64
70
grpctest.Tester
@@ -177,7 +183,7 @@ func (s) TestPickFirstLeaf_SimpleResolverUpdate_FirstServerReady(t *testing.T) {
177
183
wantSCStates := []scState {
178
184
{Addrs : []resolver.Address {addrs [0 ]}, State : connectivity .Ready },
179
185
}
180
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
186
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
181
187
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
182
188
}
183
189
@@ -219,7 +225,7 @@ func (s) TestPickFirstLeaf_SimpleResolverUpdate_FirstServerUnReady(t *testing.T)
219
225
{Addrs : []resolver.Address {addrs [0 ]}, State : connectivity .Shutdown },
220
226
{Addrs : []resolver.Address {addrs [1 ]}, State : connectivity .Ready },
221
227
}
222
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
228
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
223
229
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
224
230
}
225
231
@@ -264,7 +270,7 @@ func (s) TestPickFirstLeaf_SimpleResolverUpdate_DuplicateAddrs(t *testing.T) {
264
270
{Addrs : []resolver.Address {addrs [0 ]}, State : connectivity .Shutdown },
265
271
{Addrs : []resolver.Address {addrs [1 ]}, State : connectivity .Ready },
266
272
}
267
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
273
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
268
274
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
269
275
}
270
276
@@ -317,7 +323,7 @@ func (s) TestPickFirstLeaf_ResolverUpdates_DisjointLists(t *testing.T) {
317
323
{Addrs : []resolver.Address {addrs [1 ]}, State : connectivity .Ready },
318
324
}
319
325
320
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
326
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
321
327
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
322
328
}
323
329
@@ -334,7 +340,7 @@ func (s) TestPickFirstLeaf_ResolverUpdates_DisjointLists(t *testing.T) {
334
340
{Addrs : []resolver.Address {addrs [3 ]}, State : connectivity .Ready },
335
341
}
336
342
337
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
343
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
338
344
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
339
345
}
340
346
@@ -378,7 +384,7 @@ func (s) TestPickFirstLeaf_ResolverUpdates_ActiveBackendInUpdatedList(t *testing
378
384
{Addrs : []resolver.Address {addrs [1 ]}, State : connectivity .Ready },
379
385
}
380
386
381
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
387
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
382
388
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
383
389
}
384
390
@@ -398,7 +404,7 @@ func (s) TestPickFirstLeaf_ResolverUpdates_ActiveBackendInUpdatedList(t *testing
398
404
{Addrs : []resolver.Address {addrs [1 ]}, State : connectivity .Ready },
399
405
}
400
406
401
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
407
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
402
408
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
403
409
}
404
410
@@ -440,7 +446,7 @@ func (s) TestPickFirstLeaf_ResolverUpdates_InActiveBackendInUpdatedList(t *testi
440
446
{Addrs : []resolver.Address {addrs [1 ]}, State : connectivity .Ready },
441
447
}
442
448
443
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
449
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
444
450
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
445
451
}
446
452
@@ -458,7 +464,7 @@ func (s) TestPickFirstLeaf_ResolverUpdates_InActiveBackendInUpdatedList(t *testi
458
464
{Addrs : []resolver.Address {addrs [0 ]}, State : connectivity .Ready },
459
465
}
460
466
461
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
467
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
462
468
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
463
469
}
464
470
@@ -502,7 +508,7 @@ func (s) TestPickFirstLeaf_ResolverUpdates_IdenticalLists(t *testing.T) {
502
508
{Addrs : []resolver.Address {addrs [1 ]}, State : connectivity .Ready },
503
509
}
504
510
505
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
511
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
506
512
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
507
513
}
508
514
@@ -521,7 +527,7 @@ func (s) TestPickFirstLeaf_ResolverUpdates_IdenticalLists(t *testing.T) {
521
527
{Addrs : []resolver.Address {addrs [1 ]}, State : connectivity .Ready },
522
528
}
523
529
524
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
530
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
525
531
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
526
532
}
527
533
@@ -576,7 +582,7 @@ func (s) TestPickFirstLeaf_StopConnectedServer_FirstServerRestart(t *testing.T)
576
582
{Addrs : []resolver.Address {addrs [0 ]}, State : connectivity .Ready },
577
583
}
578
584
579
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
585
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
580
586
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
581
587
}
582
588
@@ -591,7 +597,7 @@ func (s) TestPickFirstLeaf_StopConnectedServer_FirstServerRestart(t *testing.T)
591
597
t .Fatal (err )
592
598
}
593
599
594
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
600
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
595
601
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
596
602
}
597
603
@@ -639,7 +645,7 @@ func (s) TestPickFirstLeaf_StopConnectedServer_SecondServerRestart(t *testing.T)
639
645
{Addrs : []resolver.Address {addrs [1 ]}, State : connectivity .Ready },
640
646
}
641
647
642
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
648
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
643
649
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
644
650
}
645
651
@@ -660,7 +666,7 @@ func (s) TestPickFirstLeaf_StopConnectedServer_SecondServerRestart(t *testing.T)
660
666
{Addrs : []resolver.Address {addrs [0 ]}, State : connectivity .Shutdown },
661
667
}
662
668
663
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
669
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
664
670
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
665
671
}
666
672
@@ -708,7 +714,7 @@ func (s) TestPickFirstLeaf_StopConnectedServer_SecondServerToFirst(t *testing.T)
708
714
{Addrs : []resolver.Address {addrs [1 ]}, State : connectivity .Ready },
709
715
}
710
716
711
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
717
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
712
718
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
713
719
}
714
720
@@ -729,7 +735,7 @@ func (s) TestPickFirstLeaf_StopConnectedServer_SecondServerToFirst(t *testing.T)
729
735
{Addrs : []resolver.Address {addrs [0 ]}, State : connectivity .Ready },
730
736
}
731
737
732
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
738
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
733
739
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
734
740
}
735
741
@@ -776,7 +782,7 @@ func (s) TestPickFirstLeaf_StopConnectedServer_FirstServerToSecond(t *testing.T)
776
782
{Addrs : []resolver.Address {addrs [0 ]}, State : connectivity .Ready },
777
783
}
778
784
779
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
785
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
780
786
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
781
787
}
782
788
@@ -796,7 +802,7 @@ func (s) TestPickFirstLeaf_StopConnectedServer_FirstServerToSecond(t *testing.T)
796
802
{Addrs : []resolver.Address {addrs [1 ]}, State : connectivity .Ready },
797
803
}
798
804
799
- if diff := cmp .Diff (wantSCStates , bal .subConnStates ()); diff != "" {
805
+ if diff := cmp .Diff (wantSCStates , bal .subConnStates (), ignoreBalAttributesOpt ); diff != "" {
800
806
t .Errorf ("SubConn states mismatch (-want +got):\n %s" , diff )
801
807
}
802
808
@@ -1130,7 +1136,7 @@ func (s) TestPickFirstLeaf_InterleavingIPV4Preffered(t *testing.T) {
1130
1136
if err != nil {
1131
1137
t .Fatalf ("%v" , err )
1132
1138
}
1133
- if diff := cmp .Diff (wantAddrs , gotAddrs ); diff != "" {
1139
+ if diff := cmp .Diff (wantAddrs , gotAddrs , ignoreBalAttributesOpt ); diff != "" {
1134
1140
t .Errorf ("SubConn creation order mismatch (-want +got):\n %s" , diff )
1135
1141
}
1136
1142
}
@@ -1174,7 +1180,7 @@ func (s) TestPickFirstLeaf_InterleavingIPv6Preffered(t *testing.T) {
1174
1180
if err != nil {
1175
1181
t .Fatalf ("%v" , err )
1176
1182
}
1177
- if diff := cmp .Diff (wantAddrs , gotAddrs ); diff != "" {
1183
+ if diff := cmp .Diff (wantAddrs , gotAddrs , ignoreBalAttributesOpt ); diff != "" {
1178
1184
t .Errorf ("SubConn creation order mismatch (-want +got):\n %s" , diff )
1179
1185
}
1180
1186
}
@@ -1220,7 +1226,7 @@ func (s) TestPickFirstLeaf_InterleavingUnknownPreffered(t *testing.T) {
1220
1226
if err != nil {
1221
1227
t .Fatalf ("%v" , err )
1222
1228
}
1223
- if diff := cmp .Diff (wantAddrs , gotAddrs ); diff != "" {
1229
+ if diff := cmp .Diff (wantAddrs , gotAddrs , ignoreBalAttributesOpt ); diff != "" {
1224
1230
t .Errorf ("SubConn creation order mismatch (-want +got):\n %s" , diff )
1225
1231
}
1226
1232
}
0 commit comments