Bladeren bron

etcd-runner:add flags in watcher for hardcoded values

sharat 9 jaren geleden
bovenliggende
commit
d0f301adb7

+ 7 - 2
tools/functional-tester/etcd-runner/command/global.go

@@ -26,8 +26,13 @@ import (
 )
 )
 
 
 var (
 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
 // GlobalFlags are flags that defined globally

+ 8 - 8
tools/functional-tester/etcd-runner/command/watch_command.go

@@ -36,6 +36,11 @@ func NewWatchCommand() *cobra.Command {
 		Run:   runWatcherFunc,
 		Run:   runWatcherFunc,
 	}
 	}
 	cmd.Flags().IntVar(&rounds, "rounds", 100, "number of rounds to run")
 	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
 	return cmd
 }
 }
 
 
@@ -52,14 +57,9 @@ func runWatcherFunc(cmd *cobra.Command, args []string) {
 }
 }
 
 
 func performWatchOnPrefixes(ctx context.Context, cmd *cobra.Command, round int) {
 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)
 	prefixes := stringutil.UniqueStrings(5, noOfPrefixes)
-	keys := stringutil.RandomStrings(10, keyPrePrefix)
+	keys := stringutil.RandomStrings(10, keyPerPrefix)
 
 
 	roundPrefix := fmt.Sprintf("%16x", round)
 	roundPrefix := fmt.Sprintf("%16x", round)
 
 
@@ -82,7 +82,7 @@ func performWatchOnPrefixes(ctx context.Context, cmd *cobra.Command, round int)
 	}
 	}
 	revision = gr.Header.Revision
 	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()
 	defer cancel()
 
 
 	// generate and put keys in cluster
 	// generate and put keys in cluster

+ 3 - 3
tools/functional-tester/etcd-runner/main.go

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