Skip to content

Commit

Permalink
etcd-tester: 10-second timeout for stressers
Browse files Browse the repository at this point in the history
  • Loading branch information
gyuho committed Feb 17, 2016
1 parent ef2d3fe commit e785cdc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tools/functional-tester/etcd-tester/stresser.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/net/context"
"github.com/coreos/etcd/Godeps/_workspace/src/google.golang.org/grpc"
"github.com/coreos/etcd/Godeps/_workspace/src/google.golang.org/grpc/grpclog"
clientV2 "github.com/coreos/etcd/client"
clientv2 "github.com/coreos/etcd/client"
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
)

Expand Down Expand Up @@ -83,7 +83,7 @@ func (s *stresser) Stress() error {
go func(i int) {
defer wg.Done()
for {
putctx, putcancel := context.WithTimeout(ctx, 5*time.Second)
putctx, putcancel := context.WithTimeout(ctx, 10*time.Second)
_, err := kvc.Put(putctx, &pb.PutRequest{
Key: []byte(fmt.Sprintf("foo%d", rand.Intn(s.KeySuffixRange))),
Value: []byte(randStr(s.KeySize)),
Expand Down Expand Up @@ -137,7 +137,7 @@ type stresserV2 struct {
}

func (s *stresserV2) Stress() error {
cfg := clientV2.Config{
cfg := clientv2.Config{
Endpoints: []string{s.Endpoint},
Transport: &http.Transport{
Dial: (&net.Dialer{
Expand All @@ -147,19 +147,19 @@ func (s *stresserV2) Stress() error {
MaxIdleConnsPerHost: s.N,
},
}
c, err := clientV2.New(cfg)
c, err := clientv2.New(cfg)
if err != nil {
return err
}

kv := clientV2.NewKeysAPI(c)
kv := clientv2.NewKeysAPI(c)
ctx, cancel := context.WithCancel(context.Background())
s.cancel = cancel

for i := 0; i < s.N; i++ {
go func() {
for {
setctx, setcancel := context.WithTimeout(ctx, clientV2.DefaultRequestTimeout)
setctx, setcancel := context.WithTimeout(ctx, clientv2.DefaultRequestTimeout)
key := fmt.Sprintf("foo%d", rand.Intn(s.KeySuffixRange))
_, err := kv.Set(setctx, key, randStr(s.KeySize), nil)
setcancel()
Expand Down

0 comments on commit e785cdc

Please sign in to comment.