Skip to content

Commit

Permalink
*: make TestStores stable (#8522)
Browse files Browse the repository at this point in the history
close #7954

add a failpoint to make sure the offline store do not convert to tombstone

Signed-off-by: okJiang <[email protected]>
  • Loading branch information
okJiang authored Aug 22, 2024
1 parent 84138e4 commit 9e7a1b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1669,9 +1669,12 @@ func (c *RaftCluster) checkStores() {
if c.IsPrepared() {
c.updateProgress(id, store.GetAddress(), removingAction, float64(regionSize), float64(regionSize), false /* dec */)
}
regionCount := c.GetStoreRegionCount(id)
// If the store is empty, it can be buried.
if regionCount == 0 {
needBury := c.GetStoreRegionCount(id) == 0
failpoint.Inject("doNotBuryStore", func(_ failpoint.Value) {
needBury = false
})
if needBury {
if err := c.BuryStore(id, false); err != nil {
log.Error("bury store failed",
zap.Stringer("store", offlineStore),
Expand Down
10 changes: 5 additions & 5 deletions tests/integrations/mcs/scheduling/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,13 +629,13 @@ func (suite *apiTestSuite) checkStores(cluster *tests.TestCluster) {
Version: "2.0.0",
},
}
// prevent the offline store from changing to tombstone
tests.MustPutRegion(re, cluster, 3, 6, []byte("a"), []byte("b"))

re.NoError(failpoint.Enable("github.com/tikv/pd/server/cluster/doNotBuryStore", `return(true)`))
defer func() {
re.NoError(failpoint.Disable("github.com/tikv/pd/server/cluster/doNotBuryStore"))
}()
for _, store := range stores {
tests.MustPutStore(re, cluster, store)
if store.GetId() == 6 {
cluster.GetLeaderServer().GetRaftCluster().GetBasicCluster().UpdateStoreStatus(6)
}
}
// Test /stores
apiServerAddr := cluster.GetLeaderServer().GetAddr()
Expand Down

0 comments on commit 9e7a1b9

Please sign in to comment.