Skip to content

Commit 9745a6e

Browse files
committed
update
1 parent e0195bc commit 9745a6e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

internal/gateway/grpc_proxy_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
stdCtx "context"
1919
"fmt"
2020
"net"
21+
"sync"
2122
"testing"
2223
"time"
2324

@@ -86,16 +87,23 @@ func Test_A(t *testing.T) {
8687
LeaderAddr: "127.0.0.1:20001",
8788
GatewayAddr: "127.0.0.1:12345",
8889
}
90+
mutex := sync.Mutex{}
8991
pingSvc1.EXPECT().Ping(gomock.Any(), gomock.Any()).AnyTimes().DoAndReturn(func(ctx stdCtx.Context,
9092
in *emptypb.Empty) (*ctrlpb.PingResponse, error) {
93+
mutex.Lock()
94+
defer mutex.Unlock()
9195
return pingRes, nil
9296
})
9397
pingSvc2.EXPECT().Ping(gomock.Any(), gomock.Any()).AnyTimes().DoAndReturn(func(ctx stdCtx.Context,
9498
in *emptypb.Empty) (*ctrlpb.PingResponse, error) {
99+
mutex.Lock()
100+
defer mutex.Unlock()
95101
return pingRes, nil
96102
})
97103
pingSvc3.EXPECT().Ping(gomock.Any(), gomock.Any()).AnyTimes().DoAndReturn(func(ctx stdCtx.Context,
98104
in *emptypb.Empty) (*ctrlpb.PingResponse, error) {
105+
mutex.Lock()
106+
defer mutex.Unlock()
99107
return pingRes, nil
100108
})
101109

@@ -118,7 +126,9 @@ func Test_A(t *testing.T) {
118126
So(res.LeaderAddr, ShouldEqual, "127.0.0.1:20001")
119127
So(res.GatewayAddr, ShouldEqual, "127.0.0.1:12345")
120128

129+
mutex.Lock()
121130
pingRes.LeaderAddr = "127.0.0.1:20003"
131+
mutex.Unlock()
122132
time.Sleep(100 * time.Millisecond)
123133
res, err = pingCli.Ping(stdCtx.Background(), &empty.Empty{})
124134
So(err, ShouldBeNil)

0 commit comments

Comments
 (0)