Skip to content

Commit

Permalink
Review comments #2.
Browse files Browse the repository at this point in the history
  • Loading branch information
easwars committed Aug 27, 2020
1 parent 6fc6be3 commit deaaaf0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
7 changes: 5 additions & 2 deletions xds/internal/balancer/edsbalancer/xds_client_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ func (s) TestClientWrapperHandleUpdateError(t *testing.T) {

xdsC := fakeclient.NewClient()
cw.handleUpdate(&EDSConfig{EDSServiceName: testEDSClusterName}, attributes.New(xdsinternal.XDSClientID, xdsC))
gotCluster, err := xdsC.WaitForWatchEDS(context.Background())

ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
defer cancel()
gotCluster, err := xdsC.WaitForWatchEDS(ctx)
if err != nil {
t.Fatalf("xdsClient.WatchEndpoints failed with error: %v", err)
}
Expand All @@ -181,7 +184,7 @@ func (s) TestClientWrapperHandleUpdateError(t *testing.T) {
//
// TODO: check for loseContact() when errors indicating "lose contact" are
// handled correctly.
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
ctx, cancel = context.WithTimeout(context.Background(), defaultTestTimeout)
defer cancel()
gotUpdate, err := edsRespChan.Receive(ctx)
if err != nil {
Expand Down
14 changes: 9 additions & 5 deletions xds/internal/balancer/edsbalancer/xds_lrs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package edsbalancer

import (
context2 "context"
"context"
"testing"

"google.golang.org/grpc/attributes"
Expand All @@ -42,20 +42,24 @@ func (s) TestXDSLoadReporting(t *testing.T) {
defer edsB.Close()

xdsC := fakeclient.NewClient()
edsB.UpdateClientConnState(balancer.ClientConnState{
if err := edsB.UpdateClientConnState(balancer.ClientConnState{
ResolverState: resolver.State{Attributes: attributes.New(xdsinternal.XDSClientID, xdsC)},
BalancerConfig: &EDSConfig{LrsLoadReportingServerName: new(string)},
})
}); err != nil {
t.Fatal(err)
}

gotCluster, err := xdsC.WaitForWatchEDS(context2.Background())
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
defer cancel()
gotCluster, err := xdsC.WaitForWatchEDS(ctx)
if err != nil {
t.Fatalf("xdsClient.WatchEndpoints failed with error: %v", err)
}
if gotCluster != testEDSClusterName {
t.Fatalf("xdsClient.WatchEndpoints() called with cluster: %v, want %v", gotCluster, testEDSClusterName)
}

got, err := xdsC.WaitForReportLoad(context2.Background())
got, err := xdsC.WaitForReportLoad(ctx)
if err != nil {
t.Fatalf("xdsClient.ReportLoad failed with error: %v", err)
}
Expand Down

0 comments on commit deaaaf0

Please sign in to comment.