Skip to content

Commit

Permalink
*: make TestConfig stable (tikv#7463)
Browse files Browse the repository at this point in the history
close tikv#7440

Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
rleungx and ti-chi-bot[bot] committed Dec 1, 2023
1 parent 489c4eb commit 7ae70a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/dashboard/adapter/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"sync"
"time"

"github.com/pingcap/failpoint"
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/pingcap/log"
"github.com/pingcap/tidb-dashboard/pkg/apiserver"
Expand Down Expand Up @@ -75,6 +76,10 @@ func (m *Manager) Stop() {
func (m *Manager) serviceLoop() {
defer logutil.LogPanic()
defer m.wg.Done()
// TODO: After we fix the atomic problem of config, we can remove this failpoint.
failpoint.Inject("skipDashboardLoop", func() {
failpoint.Return()
})

ticker := time.NewTicker(CheckInterval)
defer ticker.Stop()
Expand Down
3 changes: 3 additions & 0 deletions tests/pdctl/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

"github.com/coreos/go-semver/semver"
"github.com/pingcap/failpoint"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -60,8 +61,10 @@ func TestConfigTestSuite(t *testing.T) {
}

func (suite *configTestSuite) TestConfig() {
suite.NoError(failpoint.Enable("github.com/tikv/pd/pkg/dashboard/adapter/skipDashboardLoop", `return(true)`))
env := tests.NewSchedulingTestEnvironment(suite.T())
env.RunTestInTwoModes(suite.checkConfig)
suite.NoError(failpoint.Disable("github.com/tikv/pd/pkg/dashboard/adapter/skipDashboardLoop"))
}

func (suite *configTestSuite) checkConfig(cluster *tests.TestCluster) {
Expand Down

0 comments on commit 7ae70a1

Please sign in to comment.