Merge pull request #2730 from yichengq/tester-key-param

main: parameterize stress key size and key suffix range
This commit is contained in:
Yicheng Qin 2015-04-27 17:02:36 -07:00
commit eafdd3b718
2 changed files with 15 additions and 10 deletions

View File

@ -30,8 +30,10 @@ import (
const peerURLPort = 2380 const peerURLPort = 2380
type cluster struct { type cluster struct {
agentEndpoints []string agentEndpoints []string
datadir string datadir string
stressKeySize int
stressKeySuffixRange int
Size int Size int
Agents []client.Agent Agents []client.Agent
@ -45,10 +47,12 @@ type ClusterStatus struct {
} }
// newCluster starts and returns a new cluster. The caller should call Terminate when finished, to shut it down. // newCluster starts and returns a new cluster. The caller should call Terminate when finished, to shut it down.
func newCluster(agentEndpoints []string, datadir string) (*cluster, error) { func newCluster(agentEndpoints []string, datadir string, stressKeySize, stressKeySuffixRange int) (*cluster, error) {
c := &cluster{ c := &cluster{
agentEndpoints: agentEndpoints, agentEndpoints: agentEndpoints,
datadir: datadir, datadir: datadir,
stressKeySize: stressKeySize,
stressKeySuffixRange: stressKeySuffixRange,
} }
if err := c.Bootstrap(); err != nil { if err := c.Bootstrap(); err != nil {
return nil, err return nil, err
@ -109,10 +113,9 @@ func (c *cluster) Bootstrap() error {
stressers := make([]Stresser, len(clientURLs)) stressers := make([]Stresser, len(clientURLs))
for i, u := range clientURLs { for i, u := range clientURLs {
s := &stresser{ s := &stresser{
Endpoint: u, Endpoint: u,
// 500000 100B key (50MB) KeySize: c.stressKeySize,
KeySize: 100, KeySuffixRange: c.stressKeySuffixRange,
KeySuffixRange: 500000,
N: 200, N: 200,
} }
go s.Stress() go s.Stress()

View File

@ -24,11 +24,13 @@ import (
func main() { func main() {
endpointStr := flag.String("agent-endpoints", ":9027", "") endpointStr := flag.String("agent-endpoints", ":9027", "")
datadir := flag.String("data-dir", "agent.etcd", "") datadir := flag.String("data-dir", "agent.etcd", "")
stressKeySize := flag.Int("stress-key-size", 100, "stress-key-size is the size of each key written into etcd")
stressKeySuffixRange := flag.Int("stress-key-count", 250000, "stress-key-count is the count of key range written into etcd")
limit := flag.Int("limit", 3, "") limit := flag.Int("limit", 3, "")
flag.Parse() flag.Parse()
endpoints := strings.Split(*endpointStr, ",") endpoints := strings.Split(*endpointStr, ",")
c, err := newCluster(endpoints, *datadir) c, err := newCluster(endpoints, *datadir, *stressKeySize, *stressKeySuffixRange)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }