Skip to content

Commit 6351ca4

Browse files
authored
client: fix etcd proxy loop detection error in unit test (#3576)
Signed-off-by: JmPotato <[email protected]>
1 parent 5099d55 commit 6351ca4

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

client/client_test.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ func (s *testClientSuite) TestTsLessEqual(c *C) {
4848

4949
func (s *testClientSuite) TestUpdateURLs(c *C) {
5050
members := []*pdpb.Member{
51-
{Name: "pd4", ClientUrls: []string{"tmp//pd4"}},
52-
{Name: "pd1", ClientUrls: []string{"tmp//pd1"}},
53-
{Name: "pd3", ClientUrls: []string{"tmp//pd3"}},
54-
{Name: "pd2", ClientUrls: []string{"tmp//pd2"}},
51+
{Name: "pd4", ClientUrls: []string{"tmp://pd4"}},
52+
{Name: "pd1", ClientUrls: []string{"tmp://pd1"}},
53+
{Name: "pd3", ClientUrls: []string{"tmp://pd3"}},
54+
{Name: "pd2", ClientUrls: []string{"tmp://pd2"}},
5555
}
5656
getURLs := func(ms []*pdpb.Member) (urls []string) {
5757
for _, m := range ms {
@@ -68,6 +68,8 @@ func (s *testClientSuite) TestUpdateURLs(c *C) {
6868
c.Assert(cli.urls, DeepEquals, getURLs([]*pdpb.Member{members[1], members[3], members[2], members[0]}))
6969
}
7070

71+
const testClientURL = "tmp://test.url:5255"
72+
7173
var _ = Suite(&testClientCtxSuite{})
7274

7375
type testClientCtxSuite struct{}
@@ -76,16 +78,16 @@ func (s *testClientCtxSuite) TestClientCtx(c *C) {
7678
start := time.Now()
7779
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*3)
7880
defer cancel()
79-
_, err := NewClientWithContext(ctx, []string{"127.0.0.1:8080"}, SecurityOption{})
81+
_, err := NewClientWithContext(ctx, []string{testClientURL}, SecurityOption{})
8082
c.Assert(err, NotNil)
81-
c.Assert(time.Since(start), Less, time.Second*4)
83+
c.Assert(time.Since(start), Less, time.Second*5)
8284
}
8385

8486
func (s *testClientCtxSuite) TestClientWithRetry(c *C) {
8587
start := time.Now()
86-
_, err := NewClientWithContext(context.TODO(), []string{"127.0.0.1:8080"}, SecurityOption{}, WithMaxErrorRetry(5))
88+
_, err := NewClientWithContext(context.TODO(), []string{testClientURL}, SecurityOption{}, WithMaxErrorRetry(5))
8789
c.Assert(err, NotNil)
88-
c.Assert(time.Since(start), Less, time.Second*6)
90+
c.Assert(time.Since(start), Less, time.Second*10)
8991
}
9092

9193
var _ = Suite(&testClientDialOptionSuite{})
@@ -98,7 +100,7 @@ func (s *testClientDialOptionSuite) TestGRPCDialOption(c *C) {
98100
defer cancel()
99101
// nolint
100102
cli := &baseClient{
101-
urls: []string{"http://127.0.0.1:8080"},
103+
urls: []string{testClientURL},
102104
checkLeaderCh: make(chan struct{}, 1),
103105
checkTSODispatcherCh: make(chan struct{}, 1),
104106
ctx: ctx,

0 commit comments

Comments
 (0)