etcd-runner:add flags in watcher for hardcoded values

This commit is contained in:
sharat 2017-01-03 17:03:07 +05:30
parent 5cb6dd268b
commit d0f301adb7
3 changed files with 18 additions and 13 deletions

View File

@ -26,8 +26,13 @@ import (
)
var (
rounds int
totalClientConnections int
rounds int // total number of rounds the operation needs to be performed
totalClientConnections int // total number of client connections to be made with server
noOfPrefixes int // total number of prefixes which will be watched upon
watchPerPrefix int // number of watchers per prefix
reqRate int // put request per second
totalKeys int // total number of keys for operation
runningTime time.Duration // time for which operation should be performed
)
// GlobalFlags are flags that defined globally

View File

@ -36,6 +36,11 @@ func NewWatchCommand() *cobra.Command {
Run: runWatcherFunc,
}
cmd.Flags().IntVar(&rounds, "rounds", 100, "number of rounds to run")
cmd.Flags().DurationVar(&runningTime, "running-time", 60, "number of seconds to run")
cmd.Flags().IntVar(&noOfPrefixes, "total-prefixes", 10, "total no of prefixes to use")
cmd.Flags().IntVar(&watchPerPrefix, "watch-per-prefix", 10, "number of watchers per prefix")
cmd.Flags().IntVar(&reqRate, "req-rate", 30, "rate at which put request will be performed")
cmd.Flags().IntVar(&totalKeys, "total-keys", 1000, "total number of keys to watch")
return cmd
}
@ -52,14 +57,9 @@ func runWatcherFunc(cmd *cobra.Command, args []string) {
}
func performWatchOnPrefixes(ctx context.Context, cmd *cobra.Command, round int) {
runningTime := 60 * time.Second // time for which operation should be performed
noOfPrefixes := 36 // total number of prefixes which will be watched upon
watchPerPrefix := 10 // number of watchers per prefix
reqRate := 30 // put request per second
keyPrePrefix := 30 // max number of keyPrePrefixs for put operation
keyPerPrefix := totalKeys / noOfPrefixes
prefixes := stringutil.UniqueStrings(5, noOfPrefixes)
keys := stringutil.RandomStrings(10, keyPrePrefix)
keys := stringutil.RandomStrings(10, keyPerPrefix)
roundPrefix := fmt.Sprintf("%16x", round)
@ -82,7 +82,7 @@ func performWatchOnPrefixes(ctx context.Context, cmd *cobra.Command, round int)
}
revision = gr.Header.Revision
ctxt, cancel := context.WithDeadline(ctx, time.Now().Add(runningTime))
ctxt, cancel := context.WithDeadline(ctx, time.Now().Add(runningTime*time.Second))
defer cancel()
// generate and put keys in cluster

View File

@ -24,8 +24,8 @@ import (
)
const (
cliName = "etcdctl"
cliDescription = "A simple command line client for etcd3."
cliName = "etcd-runner"
cliDescription = "Stress tests using clientv3 functionality.."
defaultDialTimeout = 2 * time.Second
)
@ -38,7 +38,7 @@ var (
rootCmd = &cobra.Command{
Use: cliName,
Short: cliDescription,
SuggestFor: []string{"etcdctl"},
SuggestFor: []string{"etcd-runner"},
}
)