func getTableID(ctx context.Context, dbAddr, dbName, table string) (int64, error) {
	dbHost, _, err := net.SplitHostPort(dbAddr)
	if err != nil {
		return 0, errors.Trace(err)
	}
	dbStatusAddr := net.JoinHostPort(dbHost, "10080")
	url := fmt.Sprintf("https://%s/schema/%s/%s", dbStatusAddr, dbName, table)
	client := newHTTPClient()
	req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
	if err != nil {
		return 0, errors.Trace(err)
	}
	resp, err := client.Do(req)
	if err != nil {
		return 0, errors.Trace(err)
	}
	defer resp.Body.Close()
	body, err := io.ReadAll(resp.Body)
	if err != nil {
		return 0, errors.Trace(err)
	}
	if resp.StatusCode != 200 {
		return 0, errors.Errorf("HTTP request to TiDB status reporter returns %v. Body: %v", resp.StatusCode, string(body))
	}
	var data model.TableInfo
	err = json.Unmarshal(body, &data)
	if err != nil {
		return 0, errors.Trace(err)
	}
	return data.ID, nil
}
getTableID of the table with specified table name.
package main
import (
	"bytes"
	"context"
	"encoding/json"
	"flag"
	"fmt"
	"io"
	"math/rand"
	"net"
	"net/http"
	"time"
	"github.com/pingcap/errors"
	"github.com/pingcap/kvproto/pkg/kvrpcpb"
	"github.com/pingcap/log"
	"github.com/pingcap/parser/model"
	"github.com/pingcap/tidb/config"
	"github.com/pingcap/tidb/kv"
	"github.com/pingcap/tidb/store/driver"
	"github.com/pingcap/tidb/tablecodec"
	"github.com/tikv/client-go/v2/oracle"
	"github.com/tikv/client-go/v2/tikv"
	"github.com/tikv/client-go/v2/tikvrpc"
	pd "github.com/tikv/pd/client"
	"go.uber.org/zap"
	"github.com/pingcap/br/pkg/httputil"
	"github.com/pingcap/br/pkg/task"
)
var (
	ca             = flag.String("ca", "", "CA certificate path for TLS connection")
	cert           = flag.String("cert", "", "certificate path for TLS connection")
	key            = flag.String("key", "", "private key path for TLS connection")
	tidbStatusAddr = flag.String("tidb", "", "TiDB status address")
	pdAddr         = flag.String("pd", "", "PD address")
	dbName         = flag.String("db", "", "Database name")
	tableName      = flag.String("table", "", "Table name")
	tableSize      = flag.Int64("table-size", 10000, "Table size, row count")
	timeout        = flag.Duration("run-timeout", time.Second*10, "The total time it executes")
	lockTTL        = flag.Duration("lock-ttl", time.Second*10, "The TTL of locks")
)
func main() {
	flag.Parse()
	if *tidbStatusAddr == "" {
		log.Panic("tidb status address is empty")
	}
	if *pdAddr == "" {
		log.Panic("pd address is empty")
	}
	if *dbName == "" {
		log.Panic("database name is empty")
	}
	if *tableName == "" {
		log.Panic("table name is empty")
	}
	ctx, cancel := context.WithTimeout(context.Background(), *timeout)
	defer cancel()
	http.DefaultClient.Timeout = *timeout
	tableID, err := getTableID(ctx, *tidbStatusAddr, *dbName, *tableName)
	if err != nil {
		log.Panic("get table id failed", zap.Error(err))
	}
	pdclient, err := pd.NewClient([]string{*pdAddr}, pd.SecurityOption{
		CAPath:   *ca,
		CertPath: *cert,
		KeyPath:  *key,
	})
	if err != nil {
		log.Panic("create pd client failed", zap.Error(err))
	}
	pdcli := &codecPDClient{Client: pdclient}
	if len(*ca) != 0 {
		tidbCfg := config.NewConfig()
		tidbCfg.Security.ClusterSSLCA = *ca
		tidbCfg.Security.ClusterSSLCert = *cert
		tidbCfg.Security.ClusterSSLKey = *key
		config.StoreGlobalConfig(tidbCfg)
	}
	driver := driver.TiKVDriver{}
	store, err := driver.Open(fmt.Sprintf("tikv://%s?disableGC=true", *pdAddr))
	if err != nil {
		log.Panic("create tikv client failed", zap.Error(err))
	}
	locker := Locker{
		tableID:   tableID,
		tableSize: *tableSize,
		lockTTL:   *lockTTL,
		pdcli:     pdcli,
		kv:        store.(tikv.Storage),
	}
	err = locker.generateLocks(ctx)
	if err != nil {
		log.Panic("generate locks failed", zap.Error(err))
	}
}
func newHTTPClient() *http.Client {
	if len(*ca) != 0 {
		tlsCfg := &task.TLSConfig{
			CA:   *ca,
			Cert: *cert,
			Key:  *key,
		}
		cfg, err := tlsCfg.ToTLSConfig()
		if err != nil {
			log.Panic("fail to parse TLS config", zap.Error(err))
		}
		return httputil.NewClient(cfg)
	}
	return http.DefaultClient
}