root.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright 2015 The etcd Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package cmd
  15. import (
  16. "sync"
  17. "time"
  18. "go.etcd.io/etcd/pkg/transport"
  19. "github.com/spf13/cobra"
  20. "gopkg.in/cheggaaa/pb.v1"
  21. )
  22. // This represents the base command when called without any subcommands
  23. var RootCmd = &cobra.Command{
  24. Use: "benchmark",
  25. Short: "A low-level benchmark tool for etcd3",
  26. Long: `benchmark is a low-level benchmark tool for etcd3.
  27. It uses gRPC client directly and does not depend on
  28. etcd client library.
  29. `,
  30. }
  31. var (
  32. endpoints []string
  33. totalConns uint
  34. totalClients uint
  35. precise bool
  36. sample bool
  37. bar *pb.ProgressBar
  38. wg sync.WaitGroup
  39. tls transport.TLSInfo
  40. cpuProfPath string
  41. memProfPath string
  42. user string
  43. dialTimeout time.Duration
  44. targetLeader bool
  45. )
  46. func init() {
  47. RootCmd.PersistentFlags().StringSliceVar(&endpoints, "endpoints", []string{"127.0.0.1:2379"}, "gRPC endpoints")
  48. RootCmd.PersistentFlags().UintVar(&totalConns, "conns", 1, "Total number of gRPC connections")
  49. RootCmd.PersistentFlags().UintVar(&totalClients, "clients", 1, "Total number of gRPC clients")
  50. RootCmd.PersistentFlags().BoolVar(&precise, "precise", false, "use full floating point precision")
  51. RootCmd.PersistentFlags().BoolVar(&sample, "sample", false, "'true' to sample requests for every second")
  52. RootCmd.PersistentFlags().StringVar(&tls.CertFile, "cert", "", "identify HTTPS client using this SSL certificate file")
  53. RootCmd.PersistentFlags().StringVar(&tls.KeyFile, "key", "", "identify HTTPS client using this SSL key file")
  54. RootCmd.PersistentFlags().StringVar(&tls.TrustedCAFile, "cacert", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
  55. RootCmd.PersistentFlags().StringVar(&user, "user", "", "provide username[:password] and prompt if password is not supplied.")
  56. RootCmd.PersistentFlags().DurationVar(&dialTimeout, "dial-timeout", 0, "dial timeout for client connections")
  57. RootCmd.PersistentFlags().BoolVar(&targetLeader, "target-leader", false, "connect only to the leader node")
  58. }