From e65ea40163387b1f882987e183795d7bdfd42abb Mon Sep 17 00:00:00 2001 From: bufferflies <1045931706@qq.com> Date: Fri, 2 Feb 2024 09:53:48 +0800 Subject: [PATCH] add case for scale in and out Signed-off-by: bufferflies <1045931706@qq.com> --- tools/pd-simulator/README.md | 11 +++++++++++ .../pd-simulator/simulator/cases/scale_tikv.go | 18 ++++-------------- tools/pd-simulator/simulator/node.go | 1 + 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/tools/pd-simulator/README.md b/tools/pd-simulator/README.md index c47024fc24b..107f6c40f64 100644 --- a/tools/pd-simulator/README.md +++ b/tools/pd-simulator/README.md @@ -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 +``` \ No newline at end of file diff --git a/tools/pd-simulator/simulator/cases/scale_tikv.go b/tools/pd-simulator/simulator/cases/scale_tikv.go index a9acac00cb5..8dce947379d 100644 --- a/tools/pd-simulator/simulator/cases/scale_tikv.go +++ b/tools/pd-simulator/simulator/cases/scale_tikv.go @@ -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 { @@ -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 diff --git a/tools/pd-simulator/simulator/node.go b/tools/pd-simulator/simulator/node.go index 68a10a8638e..8b2e43bc1d7 100644 --- a/tools/pd-simulator/simulator/node.go +++ b/tools/pd-simulator/simulator/node.go @@ -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()), }, }