Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <[email protected]>
  • Loading branch information
lhy1024 committed Aug 22, 2024
1 parent 9b255cb commit 6f1c516
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pkg/utils/etcdutil/etcdutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func checkEtcdClientHealth(re *require.Assertions, client *clientv3.Client) {

func TestEtcdScaleInAndOut(t *testing.T) {
re := require.New(t)
re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/utils/etcdutil/fastTick", "return(true)"))
// Start a etcd server.
servers, _, clean := NewTestEtcdCluster(t, 1)
defer clean()
Expand All @@ -249,6 +250,7 @@ func TestEtcdScaleInAndOut(t *testing.T) {
_, err = RemoveEtcdMember(client1, uint64(etcd1.Server.ID()))
re.NoError(err)
checkMembers(re, client2, []*embed.Etcd{etcd2})
re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/utils/etcdutil/fastTick"))
}

func TestRandomKillEtcd(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions pkg/utils/etcdutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ func MustAddEtcdMember(t *testing.T, cfg1 *embed.Config, client *clientv3.Client
peerURL := cfg2.ListenPeerUrls[0].String()
addResp, err := AddEtcdMember(client, []string{peerURL})
re.NoError(err)
// Start the new etcd member.
etcd2, err := embed.StartEtcd(cfg2)
re.NoError(err)
re.Equal(uint64(etcd2.Server.ID()), addResp.Member.ID)
<-etcd2.Server.ReadyNotify()
// Check the client can get the new member.
testutil.Eventually(re, func() bool {
members, err := ListEtcdMembers(client.Ctx(), client)
re.NoError(err)
return len(addResp.Members) == len(members.Members)
})
// Start the new etcd member.
etcd2, err := embed.StartEtcd(cfg2)
re.NoError(err)
re.Equal(uint64(etcd2.Server.ID()), addResp.Member.ID)
<-etcd2.Server.ReadyNotify()
return etcd2
}

Expand Down

0 comments on commit 6f1c516

Please sign in to comment.