-
Notifications
You must be signed in to change notification settings - Fork 728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tools/simulator: Make simulator work with large scale cluster #8269
Changes from 1 commit
624f934
64f0fad
0415f12
3553c7d
888024f
2fb6933
9df66c0
4468b3b
e39ec5e
da5dc4c
fc3f590
bf58b48
3aecdb5
a3888a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2024 TiKV Project Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cases | ||
|
||
import ( | ||
"github.com/docker/go-units" | ||
"github.com/pingcap/kvproto/pkg/metapb" | ||
"github.com/tikv/pd/pkg/core" | ||
sc "github.com/tikv/pd/tools/pd-simulator/simulator/config" | ||
"github.com/tikv/pd/tools/pd-simulator/simulator/info" | ||
"github.com/tikv/pd/tools/pd-simulator/simulator/simutil" | ||
) | ||
|
||
// newStableEnv provides a stable environment for test. | ||
func newStableEnv(config *sc.SimConfig) *Case { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible that we just create a cluster with a fixed region and store rather than cases? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may not be an easy thing for the current simulator code structure |
||
var simCase Case | ||
|
||
totalStore := config.TotalStore | ||
totalRegion := config.TotalRegion | ||
allStores := make(map[uint64]struct{}, totalStore) | ||
arrStoresID := make([]uint64, 0, totalStore) | ||
replica := int(config.ServerConfig.Replication.MaxReplicas) | ||
for i := 0; i < totalStore; i++ { | ||
id := simutil.IDAllocator.NextID() | ||
simCase.Stores = append(simCase.Stores, &Store{ | ||
ID: id, | ||
Status: metapb.StoreState_Up, | ||
}) | ||
allStores[id] = struct{}{} | ||
arrStoresID = append(arrStoresID, id) | ||
} | ||
|
||
for i := 0; i < totalRegion; i++ { | ||
peers := make([]*metapb.Peer, 0, replica) | ||
for j := 0; j < replica; j++ { | ||
peers = append(peers, &metapb.Peer{ | ||
Id: simutil.IDAllocator.NextID(), | ||
StoreId: arrStoresID[(i+j)%totalStore], | ||
}) | ||
} | ||
simCase.Regions = append(simCase.Regions, Region{ | ||
ID: simutil.IDAllocator.NextID(), | ||
Peers: peers, | ||
Leader: peers[0], | ||
Size: 96 * units.MiB, | ||
Keys: 960000, | ||
}) | ||
} | ||
|
||
simCase.Checker = func(_ *core.RegionsInfo, _ []info.StoreStats) bool { | ||
if len(allStores) == 0 { | ||
return false | ||
} | ||
HuSharp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return false | ||
} | ||
return &simCase | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do other cases work? like scale in/out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I have tested in

balance-leader
as wellThe
stable
case is convenient for add/remove node