Skip to content

Commit

Permalink
tools: remove trim scheme (#7769)
Browse files Browse the repository at this point in the history
ref #7703

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
CabinfeverB and ti-chi-bot[bot] committed Jan 29, 2024
1 parent 7142cf4 commit cf02b18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
9 changes: 5 additions & 4 deletions tools/pd-api-bench/cases/cases.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ package cases
import (
"context"
"fmt"
"log"
"math/rand"

"github.com/pingcap/log"
pd "github.com/tikv/pd/client"
pdHttp "github.com/tikv/pd/client/http"
"go.etcd.io/etcd/clientv3"
"go.uber.org/zap"
)

var (
Expand Down Expand Up @@ -51,7 +52,7 @@ func InitCluster(ctx context.Context, cli pd.Client, httpCli pdHttp.Client) erro
for _, store := range stores {
storesID = append(storesID, store.GetId())
}
log.Printf("This cluster has region %d, and store %d[%v]", totalRegion, totalStore, storesID)
log.Info("init cluster info", zap.Int("total-region", totalRegion), zap.Int("total-store", totalStore), zap.Any("store-ids", storesID))
return nil
}

Expand Down Expand Up @@ -182,7 +183,7 @@ func newMinResolvedTS() func() HTTPCase {
func (c *minResolvedTS) Do(ctx context.Context, cli pdHttp.Client) error {
minResolvedTS, storesMinResolvedTS, err := cli.GetMinResolvedTSByStoresIDs(ctx, storesID)
if Debug {
log.Printf("Do %s: minResolvedTS: %d storesMinResolvedTS: %v err: %v", c.name, minResolvedTS, storesMinResolvedTS, err)
log.Info("do HTTP case", zap.String("case", c.name), zap.Uint64("min-resolved-ts", minResolvedTS), zap.Any("store-min-resolved-ts", storesMinResolvedTS), zap.Error(err))
}
if err != nil {
return err
Expand Down Expand Up @@ -218,7 +219,7 @@ func (c *regionsStats) Do(ctx context.Context, cli pdHttp.Client) error {
regionStats, err := cli.GetRegionStatusByKeyRange(ctx,
pdHttp.NewKeyRange(generateKeyForSimulator(startID, 56), generateKeyForSimulator(endID, 56)), false)
if Debug {
log.Printf("Do %s: regionStats: %v err: %v", c.name, regionStats, err)
log.Info("do HTTP case", zap.String("case", c.name), zap.Any("region-stats", regionStats), zap.Error(err))
}
if err != nil {
return err
Expand Down
10 changes: 2 additions & 8 deletions tools/pd-api-bench/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,6 @@ func runHTTPServer(cfg *config.Config, co *cases.Coordinator) {
engine.Run(cfg.StatusAddr)
}

func trimHTTPPrefix(str string) string {
str = strings.TrimPrefix(str, "http://")
str = strings.TrimPrefix(str, "https://")
return str
}

const (
keepaliveTime = 10 * time.Second
keepaliveTimeout = 3 * time.Second
Expand All @@ -369,7 +363,7 @@ func newEtcdClient(cfg *config.Config) *clientv3.Client {
return nil
}
clientConfig := clientv3.Config{
Endpoints: []string{trimHTTPPrefix(cfg.PDAddr)},
Endpoints: []string{cfg.PDAddr},
DialTimeout: keepaliveTimeout,
TLS: tlsCfg,
LogConfig: &lgc,
Expand All @@ -383,7 +377,7 @@ func newEtcdClient(cfg *config.Config) *clientv3.Client {

// newPDClient returns a pd client.
func newPDClient(ctx context.Context, cfg *config.Config) pd.Client {
addrs := []string{trimHTTPPrefix(cfg.PDAddr)}
addrs := []string{cfg.PDAddr}
pdCli, err := pd.NewClientWithContext(ctx, addrs, pd.SecurityOption{
CAPath: cfg.CaPath,
CertPath: cfg.CertPath,
Expand Down

0 comments on commit cf02b18

Please sign in to comment.