Skip to content

Commit

Permalink
config: disable EnableV2 of etcd (#8536)
Browse files Browse the repository at this point in the history
close #8535

Signed-off-by: lhy1024 <admin@liudos.us>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
lhy1024 and ti-chi-bot[bot] authored Aug 16, 2024
1 parent 4b0878e commit 10cbdcf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
25 changes: 11 additions & 14 deletions server/api/member_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
package api

import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"math/rand"
"net/http"
Expand All @@ -31,6 +30,7 @@ import (
"github.com/tikv/pd/pkg/utils/testutil"
"github.com/tikv/pd/server"
"github.com/tikv/pd/server/config"
clientv3 "go.etcd.io/etcd/client/v3"
)

type memberTestSuite struct {
Expand Down Expand Up @@ -124,11 +124,10 @@ func (suite *memberTestSuite) TestChangeLeaderPeerUrls() {

var got pdpb.Member
re.NoError(json.Unmarshal(buf, &got))
id := got.GetMemberId()
peerUrls := got.GetPeerUrls()

newPeerUrls := []string{"http://127.0.0.1:1111"}
suite.changeLeaderPeerUrls(leader, id, newPeerUrls)
suite.changeLeaderPeerUrls(leader, newPeerUrls)
addr = suite.cfgs[rand.Intn(len(suite.cfgs))].ClientUrls + apiPrefix + "/api/v1/members"
resp, err = testDialClient.Get(addr)
re.NoError(err)
Expand All @@ -141,21 +140,19 @@ func (suite *memberTestSuite) TestChangeLeaderPeerUrls() {
re.Equal(newPeerUrls, got1["etcd_leader"].GetPeerUrls())

// reset
suite.changeLeaderPeerUrls(leader, id, peerUrls)
suite.changeLeaderPeerUrls(leader, peerUrls)
}

func (suite *memberTestSuite) changeLeaderPeerUrls(leader *pdpb.Member, id uint64, urls []string) {
func (suite *memberTestSuite) changeLeaderPeerUrls(leader *pdpb.Member, urls []string) {
re := suite.Require()
data := map[string][]string{"peerURLs": urls}
postData, err := json.Marshal(data)
re.NoError(err)
req, err := http.NewRequest(http.MethodPut, fmt.Sprintf("%s/v2/members/%s", leader.GetClientUrls()[0], fmt.Sprintf("%x", id)), bytes.NewBuffer(postData))

cli, err := clientv3.New(clientv3.Config{
Endpoints: leader.GetClientUrls(),
})
re.NoError(err)
req.Header.Set("Content-Type", "application/json")
resp, err := testDialClient.Do(req)
_, err = cli.MemberUpdate(context.Background(), leader.GetMemberId(), urls)
re.NoError(err)
re.Equal(204, resp.StatusCode)
resp.Body.Close()
cli.Close()
}

func (suite *memberTestSuite) TestResignMyself() {
Expand Down
1 change: 0 additions & 1 deletion server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,6 @@ func (c *Config) GenEmbedEtcdConfig() (*embed.Config, error) {
cfg.ForceNewCluster = c.ForceNewCluster
cfg.ZapLoggerBuilder = embed.NewZapCoreLoggerBuilder(c.Logger, c.Logger.Core(), c.LogProps.Syncer)
cfg.EnableGRPCGateway = c.EnableGRPCGateway
cfg.EnableV2 = true
cfg.Logger = "zap"
var err error

Expand Down

0 comments on commit 10cbdcf

Please sign in to comment.