Skip to content

Commit

Permalink
*: make TestConfig stable (#7463)
Browse files Browse the repository at this point in the history
close #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] authored Nov 29, 2023
1 parent a6e855e commit 8c8b4d4
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 8c8b4d4

Please sign in to comment.