Skip to content

Commit 83317b1

Browse files
committed
resolving comments
1 parent 88e547e commit 83317b1

3 files changed

Lines changed: 29 additions & 29 deletions

File tree

internal/xds/balancer/cdsbalancer/e2e_test/dns_impl_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (s) TestLogicalDNS_MultipleEndpoints(t *testing.T) {
6565
server2 := stubserver.StartTestService(t, nil)
6666
defer server2.Stop()
6767

68-
// Register a manual resolver with the "dns" scheme to mock DNS resolution.
68+
// Register a manual resolver with the "dns" scheme to override DNS resolution.
6969
// This global override is safe because connection to the xDS management
7070
// server uses the passthrough scheme instead and therefore overriding
7171
// the DNS resolver does not affect it in any way.
@@ -77,10 +77,11 @@ func (s) TestLogicalDNS_MultipleEndpoints(t *testing.T) {
7777

7878
// For LOGICAL_DNS, this updates the SINGLE endpoint to have 2 IPs.
7979
dnsR.InitialState(resolver.State{
80-
Addresses: []resolver.Address{
81-
{Addr: server1.Address},
82-
{Addr: server2.Address},
83-
},
80+
Endpoints: []resolver.Endpoint{{
81+
Addresses: []resolver.Address{
82+
{Addr: server1.Address},
83+
{Addr: server2.Address},
84+
}}},
8485
})
8586

8687
const (

internal/xds/balancer/clusterresolver/configbuilder.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ func buildClusterImplConfigForDNS(g *nameGenerator, endpoints []resolver.Endpoin
163163
// LB policies that rely on locality information (like weighted_target)
164164
// continue to work.
165165
localityStr := xdsinternal.LocalityString(clients.Locality{})
166-
retEndpoint = hierarchy.SetInEndpoint(retEndpoint, []string{pName, localityStr})
166+
retEndpoint = xdsresource.SetHostname(hierarchy.SetInEndpoint(retEndpoint, []string{pName, localityStr}), mechanism.DNSHostname)
167167
// Set the locality weight to 1. This is required because the child policy
168-
// like wrr which relies on locality weights to distribute traffic. These
169-
// policies may drop traffic if the weight is 0.
168+
// like weighted_target which relies on locality weights to distribute
169+
// traffic. These policies may drop traffic if the weight is 0.
170170
retEndpoint = wrrlocality.SetAddrInfo(retEndpoint, wrrlocality.AddrInfo{LocalityWeight: 1})
171171
return pName, lbconfig, []resolver.Endpoint{retEndpoint}
172172
}

internal/xds/balancer/clusterresolver/configbuilder_test.go

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ func testEndpointForDNS(endpoints []resolver.Endpoint, localityWeight uint32, pa
319319
}
320320

321321
func (s) TestBuildClusterImplConfigForDNS(t *testing.T) {
322-
323322
for _, tt := range []struct {
324323
name string
325324
endpoints []resolver.Endpoint
@@ -364,21 +363,21 @@ func (s) TestBuildClusterImplConfigForDNS(t *testing.T) {
364363
t.Run(tt.name, func(t *testing.T) {
365364
gotName, gotConfig, gotEndpoints := buildClusterImplConfigForDNS(newNameGenerator(3), tt.endpoints, DiscoveryMechanism{Cluster: testClusterName2, Type: DiscoveryMechanismTypeLogicalDNS}, tt.xdsLBPolicy)
366365
const wantName = "priority-3"
367-
if diff := cmp.Diff(gotName, wantName); diff != "" {
368-
t.Errorf("buildClusterImplConfigForDNS() diff (-got +want) %v", diff)
366+
if diff := cmp.Diff(wantName, gotName); diff != "" {
367+
t.Errorf("buildClusterImplConfigForDNS() diff (-want +got) %v", diff)
369368
}
370369

371370
wantConfig := &clusterimpl.LBConfig{
372371
Cluster: testClusterName2,
373372
ChildPolicy: tt.xdsLBPolicy,
374373
}
375-
if diff := cmp.Diff(gotConfig, wantConfig); diff != "" {
376-
t.Errorf("buildClusterImplConfigForDNS() diff (-got +want) %v", diff)
374+
if diff := cmp.Diff(wantConfig, gotConfig); diff != "" {
375+
t.Errorf("buildClusterImplConfigForDNS() diff (-want +got) %v", diff)
377376
}
378377

379378
wantEndpoints := []resolver.Endpoint{testEndpointForDNS(tt.endpoints, 1, []string{wantName, xdsinternal.LocalityString(clients.Locality{})})}
380-
if diff := cmp.Diff(gotEndpoints, wantEndpoints, endpointCmpOpts); diff != "" {
381-
t.Errorf("buildClusterImplConfigForDNS() diff (-got +want) %v", diff)
379+
if diff := cmp.Diff(wantEndpoints, gotEndpoints, endpointCmpOpts); diff != "" {
380+
t.Errorf("buildClusterImplConfigForDNS() diff (-want +got) %v", diff)
382381
}
383382
})
384383
}
@@ -478,14 +477,14 @@ func (s) TestBuildClusterImplConfigForEDS(t *testing.T) {
478477
testEndpointWithAttrs(testEndpoints[3][1].ResolverEndpoint, 80, 1, "priority-2-1", &testLocalityIDs[3]),
479478
}
480479

481-
if diff := cmp.Diff(gotNames, wantNames); diff != "" {
482-
t.Errorf("buildClusterImplConfigForEDS() diff (-got +want) %v", diff)
480+
if diff := cmp.Diff(wantNames, gotNames); diff != "" {
481+
t.Errorf("buildClusterImplConfigForEDS() diff (-want +got) %v", diff)
483482
}
484-
if diff := cmp.Diff(gotConfigs, wantConfigs); diff != "" {
485-
t.Errorf("buildClusterImplConfigForEDS() diff (-got +want) %v", diff)
483+
if diff := cmp.Diff(wantConfigs, gotConfigs); diff != "" {
484+
t.Errorf("buildClusterImplConfigForEDS() diff (-want +got) %v", diff)
486485
}
487-
if diff := cmp.Diff(gotEndpoints, wantEndpoints, endpointCmpOpts); diff != "" {
488-
t.Errorf("buildClusterImplConfigForEDS() diff (-got +want) %v", diff)
486+
if diff := cmp.Diff(wantEndpoints, gotEndpoints, endpointCmpOpts); diff != "" {
487+
t.Errorf("buildClusterImplConfigForEDS() diff (-want +got) %v", diff)
489488
}
490489

491490
}
@@ -545,8 +544,8 @@ func (s) TestGroupLocalitiesByPriority(t *testing.T) {
545544
for _, tt := range tests {
546545
t.Run(tt.name, func(t *testing.T) {
547546
gotLocalities := groupLocalitiesByPriority(tt.localities)
548-
if diff := cmp.Diff(gotLocalities, tt.wantLocalities); diff != "" {
549-
t.Errorf("groupLocalitiesByPriority() diff(-got +want) %v", diff)
547+
if diff := cmp.Diff(tt.wantLocalities, gotLocalities); diff != "" {
548+
t.Errorf("groupLocalitiesByPriority() diff(-want +got) %v", diff)
550549
}
551550
})
552551
}
@@ -708,11 +707,11 @@ func (s) TestPriorityLocalitiesToClusterImpl(t *testing.T) {
708707
if (err != nil) != tt.wantErr {
709708
t.Fatalf("priorityLocalitiesToClusterImpl() error = %v, wantErr %v", err, tt.wantErr)
710709
}
711-
if diff := cmp.Diff(got, tt.wantConfig); diff != "" {
712-
t.Errorf("localitiesToWeightedTarget() diff (-got +want) %v", diff)
710+
if diff := cmp.Diff(tt.wantConfig, got); diff != "" {
711+
t.Errorf("localitiesToWeightedTarget() diff (-want +got) %v", diff)
713712
}
714-
if diff := cmp.Diff(got1, tt.wantEndpoints, cmp.AllowUnexported(attributes.Attributes{})); diff != "" {
715-
t.Errorf("localitiesToWeightedTarget() diff (-got +want) %v", diff)
713+
if diff := cmp.Diff(tt.wantEndpoints, got1, cmp.AllowUnexported(attributes.Attributes{})); diff != "" {
714+
t.Errorf("localitiesToWeightedTarget() diff (-want +got) %v", diff)
716715
}
717716
})
718717
}
@@ -797,8 +796,8 @@ func (s) TestConvertClusterImplMapToOutlierDetection(t *testing.T) {
797796
for _, test := range tests {
798797
t.Run(test.name, func(t *testing.T) {
799798
got := convertClusterImplMapToOutlierDetection(test.ciCfgsMap, test.odCfg)
800-
if diff := cmp.Diff(got, test.wantODCfgs); diff != "" {
801-
t.Fatalf("convertClusterImplMapToOutlierDetection() diff(-got +want) %v", diff)
799+
if diff := cmp.Diff(test.wantODCfgs, got); diff != "" {
800+
t.Fatalf("convertClusterImplMapToOutlierDetection() diff(-want +got) %v", diff)
802801
}
803802
})
804803
}

0 commit comments

Comments
 (0)