Skip to content

Commit

Permalink
add case for scale in and out
Browse files Browse the repository at this point in the history
Signed-off-by: bufferflies <1045931706@qq.com>
  • Loading branch information
bufferflies committed Feb 2, 2024
1 parent f483748 commit e65ea40
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
11 changes: 11 additions & 0 deletions tools/pd-simulator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,14 @@ Run a specific case with an external PD:
```shell
./pd-simulator -pd="http://127.0.0.1:2379" -case="casename"
```
Run with tiup playgroudn :
```shell
tiup playground nightly --host 127.0.0.1 --kv.binpath ./pd-simulator --kv=1 --db=0 --kv.config=./tikv.conf
```
tikv conf
```
case-name="redundant-balance-region"
sim-tick-interval="1s"
store-io-per-second=100
```
18 changes: 4 additions & 14 deletions tools/pd-simulator/simulator/cases/scale_tikv.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/tikv/pd/pkg/core"
"github.com/tikv/pd/tools/pd-simulator/simulator/info"
"github.com/tikv/pd/tools/pd-simulator/simulator/simutil"
"go.uber.org/zap"
)

func newScaleInOut() *Case {
Expand Down Expand Up @@ -58,31 +57,22 @@ func newScaleInOut() *Case {
scaleInTick := int64(regionNum * 3 / storeNum)
addEvent := &AddNodesDescriptor{}
addEvent.Step = func(tick int64) uint64 {
if tick > scaleInTick {
storeNum++
return uint64(storeNum)
if tick == scaleInTick {
return uint64(storeNum + 1)
}
return 0
}

removeEvent := &DeleteNodesDescriptor{}
removeEvent.Step = func(tick int64) uint64 {
if tick > scaleInTick*2 {
return uint64(storeNum)
if tick == scaleInTick*2 {
return uint64(storeNum + 1)
}
return 0
}

simCase.Events = []EventDescriptor{addEvent, removeEvent}

// storesLastUpdateTime := make([]int64, storeNum+1)
// storeLastAvailable := make([]uint64, storeNum+1)

simCase.Checker = func(regions *core.RegionsInfo, stats []info.StoreStats) bool {
newStore := stats[storeNum-1]
simutil.Logger.Info("current counts",
zap.Uint32("peer-count", newStore.GetRegionCount()),
)
return false
}
return &simCase
Expand Down
1 change: 1 addition & 0 deletions tools/pd-simulator/simulator/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func NewNode(s *cases.Store, pdAddr string, config *SimConfig) (*Node, error) {
StoreStats: pdpb.StoreStats{
StoreId: s.ID,
Capacity: uint64(config.RaftStore.Capacity),
Available: uint64(config.RaftStore.Capacity),
StartTime: uint32(time.Now().Unix()),
},
}
Expand Down

0 comments on commit e65ea40

Please sign in to comment.