benchmark: a new option for configuring dial timeout

Current benchmark doesn't have an option for configuring dial timeout
of gRPC. This commit adds --dial-timeout for the purpose. It is useful
for stopping long sticking benchmarks.
This commit is contained in:
Hitoshi Mitake 2016-12-20 14:37:01 +09:00 committed by Hitoshi Mitake
parent d62ce55584
commit a662ddefbb
2 changed files with 8 additions and 1 deletions

View File

@ -16,6 +16,7 @@ package cmd
import (
"sync"
"time"
"github.com/coreos/etcd/pkg/transport"
@ -49,6 +50,8 @@ var (
memProfPath string
user string
dialTimeout time.Duration
)
func init() {
@ -63,4 +66,5 @@ func init() {
RootCmd.PersistentFlags().StringVar(&tls.CAFile, "cacert", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
RootCmd.PersistentFlags().StringVar(&user, "user", "", "specify username and password in username:password format")
RootCmd.PersistentFlags().DurationVar(&dialTimeout, "dial-timeout", 0, "dial timeout for client connections")
}

View File

@ -33,7 +33,10 @@ var (
func mustCreateConn() *clientv3.Client {
endpoint := endpoints[dialTotal%len(endpoints)]
dialTotal++
cfg := clientv3.Config{Endpoints: []string{endpoint}}
cfg := clientv3.Config{
Endpoints: []string{endpoint},
DialTimeout: dialTimeout,
}
if !tls.Empty() {
cfgtls, err := tls.ClientConfig()
if err != nil {