diff --git a/client/retry/backoff.go b/client/retry/backoff.go index e2ca9ab3972..b47a39d8eaa 100644 --- a/client/retry/backoff.go +++ b/client/retry/backoff.go @@ -34,9 +34,11 @@ func (bo *BackOffer) Exec( fn func() error, ) error { if err := fn(); err != nil { + after := time.NewTimer(bo.nextInterval()) + defer after.Stop() select { case <-ctx.Done(): - case <-time.After(bo.nextInterval()): + case <-after.C: failpoint.Inject("backOffExecute", func() { testBackOffExecuteFlag = true }) diff --git a/pkg/schedule/operator/operator_test.go b/pkg/schedule/operator/operator_test.go index 9d924738543..c16d929f379 100644 --- a/pkg/schedule/operator/operator_test.go +++ b/pkg/schedule/operator/operator_test.go @@ -17,7 +17,6 @@ package operator import ( "context" "encoding/json" - "fmt" "sync/atomic" "testing" "time" @@ -514,7 +513,7 @@ func (suite *operatorTestSuite) TestOpStepTimeout() { }, } for i, v := range testData { - fmt.Printf("case:%d\n", i) + suite.T().Logf("case: %d", i) for _, step := range v.step { suite.Equal(v.expect, step.Timeout(v.regionSize)) } diff --git a/tests/integrations/mcs/tso/server_test.go b/tests/integrations/mcs/tso/server_test.go index 58006b87eeb..643fb3c7911 100644 --- a/tests/integrations/mcs/tso/server_test.go +++ b/tests/integrations/mcs/tso/server_test.go @@ -89,7 +89,7 @@ func (suite *tsoServerTestSuite) TearDownSuite() { func (suite *tsoServerTestSuite) TestTSOServerStartAndStopNormally() { defer func() { if r := recover(); r != nil { - fmt.Println("Recovered from an unexpected panic", r) + suite.T().Log("Recovered from an unexpected panic", r) suite.T().Errorf("Expected no panic, but something bad occurred with") } }() diff --git a/tests/pdctl/config/config_test.go b/tests/pdctl/config/config_test.go index 91d6723c2ac..badccd9becc 100644 --- a/tests/pdctl/config/config_test.go +++ b/tests/pdctl/config/config_test.go @@ -832,7 +832,6 @@ func (suite *configTestSuite) checkPDServerConfig(cluster *tests.TestCluster) { LastHeartbeat: time.Now().UnixNano(), } tests.MustPutStore(re, cluster, store) - defer cluster.Destroy() output, err := pdctl.ExecuteCommand(cmd, "-u", pdAddr, "config", "show", "server") re.NoError(err) @@ -844,7 +843,9 @@ func (suite *configTestSuite) checkPDServerConfig(cluster *tests.TestCluster) { re.Equal("table", conf.KeyType) re.Equal(typeutil.StringSlice([]string{}), conf.RuntimeServices) re.Equal("", conf.MetricStorage) - re.Equal("auto", conf.DashboardAddress) + if conf.DashboardAddress != "auto" { // dashboard has been assigned + re.Equal(leaderServer.GetAddr(), conf.DashboardAddress) + } re.Equal(int(3), conf.FlowRoundByDigit) } diff --git a/tests/server/api/rule_test.go b/tests/server/api/rule_test.go index 9176a00e66d..ffdf56b6567 100644 --- a/tests/server/api/rule_test.go +++ b/tests/server/api/rule_test.go @@ -1097,7 +1097,6 @@ func (suite *regionRuleTestSuite) checkRegionPlacementRule(cluster *tests.TestCl var label labeler.LabelRule escapedID := url.PathEscape("keyspaces/0") u = fmt.Sprintf("%s/config/region-label/rule/%s", urlPrefix, escapedID) - fmt.Println("u====", u) err = tu.ReadGetJSON(re, testDialClient, u, &label) suite.NoError(err) suite.Equal(label.ID, "keyspaces/0") diff --git a/tests/server/cluster/cluster_test.go b/tests/server/cluster/cluster_test.go index a5861f1ba43..18a82bcf0fe 100644 --- a/tests/server/cluster/cluster_test.go +++ b/tests/server/cluster/cluster_test.go @@ -1288,7 +1288,7 @@ func TestTransferLeaderForScheduler(t *testing.T) { re.NoError(err) tc.WaitLeader() // start - leaderServer := tc.GetServer(tc.GetLeader()) + leaderServer := tc.GetLeaderServer() re.NoError(leaderServer.BootstrapCluster()) rc := leaderServer.GetServer().GetRaftCluster() re.NotNil(rc) @@ -1327,7 +1327,7 @@ func TestTransferLeaderForScheduler(t *testing.T) { tc.ResignLeader() rc.Stop() tc.WaitLeader() - leaderServer = tc.GetServer(tc.GetLeader()) + leaderServer = tc.GetLeaderServer() rc1 := leaderServer.GetServer().GetRaftCluster() rc1.Start(leaderServer.GetServer()) re.NoError(err) @@ -1347,7 +1347,7 @@ func TestTransferLeaderForScheduler(t *testing.T) { tc.ResignLeader() rc1.Stop() tc.WaitLeader() - leaderServer = tc.GetServer(tc.GetLeader()) + leaderServer = tc.GetLeaderServer() rc = leaderServer.GetServer().GetRaftCluster() rc.Start(leaderServer.GetServer()) re.NotNil(rc) diff --git a/tests/server/member/member_test.go b/tests/server/member/member_test.go index 5965f9e22a6..e6657ffd223 100644 --- a/tests/server/member/member_test.go +++ b/tests/server/member/member_test.go @@ -260,7 +260,7 @@ func TestPDLeaderLostWhileEtcdLeaderIntact(t *testing.T) { re.NoError(err) leader1 := cluster.WaitLeader() - memberID := cluster.GetServer(leader1).GetLeader().GetMemberId() + memberID := cluster.GetLeaderServer().GetLeader().GetMemberId() re.NoError(failpoint.Enable("github.com/tikv/pd/server/leaderLoopCheckAgain", fmt.Sprintf("return(\"%d\")", memberID))) re.NoError(failpoint.Enable("github.com/tikv/pd/server/exitCampaignLeader", fmt.Sprintf("return(\"%d\")", memberID))) @@ -338,7 +338,7 @@ func TestCampaignLeaderFrequently(t *testing.T) { re.NotEmpty(cluster.GetLeader()) for i := 0; i < 3; i++ { - cluster.GetServers()[cluster.GetLeader()].ResetPDLeader() + cluster.GetLeaderServer().ResetPDLeader() cluster.WaitLeader() } // leader should be changed when campaign leader frequently diff --git a/tests/server/region_syncer/region_syncer_test.go b/tests/server/region_syncer/region_syncer_test.go index b73d4abb9b5..6521432c0dc 100644 --- a/tests/server/region_syncer/region_syncer_test.go +++ b/tests/server/region_syncer/region_syncer_test.go @@ -259,7 +259,7 @@ func TestPrepareCheckerWithTransferLeader(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) cluster.WaitLeader() - leaderServer := cluster.GetServer(cluster.GetLeader()) + leaderServer := cluster.GetLeaderServer() re.NoError(leaderServer.BootstrapCluster()) rc := leaderServer.GetServer().GetRaftCluster() re.NotNil(rc)