Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: make TestConfigTestSuite stable #7398

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion client/retry/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
3 changes: 1 addition & 2 deletions pkg/schedule/operator/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package operator
import (
"context"
"encoding/json"
"fmt"
"sync/atomic"
"testing"
"time"
Expand Down Expand Up @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/mcs/tso/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}()
Expand Down
5 changes: 3 additions & 2 deletions tests/pdctl/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}

Expand Down
1 change: 0 additions & 1 deletion tests/server/api/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions tests/server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/server/member/member_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/server/region_syncer/region_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading