Skip to content

Commit

Permalink
Fix the HTTP handler tests
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <ghzpotato@gmail.com>
  • Loading branch information
JmPotato committed Nov 22, 2023
1 parent 76d5266 commit e6bed42
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions pkg/server/handler/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ go_test(
"//pkg/server/handler/optimizor",
"//pkg/server/handler/tikvhandler",
"//pkg/server/internal/testserverclient",
"//pkg/server/internal/testutil",
"//pkg/server/internal/util",
"//pkg/session",
"//pkg/sessionctx",
Expand Down
15 changes: 6 additions & 9 deletions pkg/server/handler/tests/http_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
"github.com/pingcap/tidb/pkg/server/handler/optimizor"
"github.com/pingcap/tidb/pkg/server/handler/tikvhandler"
"github.com/pingcap/tidb/pkg/server/internal/testserverclient"
"github.com/pingcap/tidb/pkg/server/internal/testutil"
"github.com/pingcap/tidb/pkg/server/internal/util"
"github.com/pingcap/tidb/pkg/session"
"github.com/pingcap/tidb/pkg/sessionctx"
Expand Down Expand Up @@ -449,26 +450,22 @@ func TestBinlogRecover(t *testing.T) {

func (ts *basicHTTPHandlerTestSuite) startServer(t *testing.T) {
var err error
ts.Port = uint(rand.Int31n(50000)) + 10000
ts.StatusPort = ts.Port + 1
ts.store, err = mockstore.NewMockStore(
mockstore.WithTiKVOptions(
tikv.WithPDHTTPClient([]string{ts.Addr()}),
),
)
ts.store, err = mockstore.NewMockStore()
require.NoError(t, err)
ts.domain, err = session.BootstrapSession(ts.store)
require.NoError(t, err)
ts.tidbdrv = server2.NewTiDBDriver(ts.store)

cfg := util.NewTestConfig()
cfg.Store = "tikv"
cfg.Port = ts.Port
cfg.Status.StatusPort = ts.StatusPort
cfg.Port = 0
cfg.Status.StatusPort = 0
cfg.Status.ReportStatus = true

server, err := server2.NewServer(cfg, ts.tidbdrv)
require.NoError(t, err)
ts.Port = testutil.GetPortFromTCPAddr(server.ListenAddr())
ts.StatusPort = testutil.GetPortFromTCPAddr(server.StatusListenerAddr())
ts.server = server
ts.server.SetDomain(ts.domain)
go func() {
Expand Down

0 comments on commit e6bed42

Please sign in to comment.