tools/etcd-tester: use stresser

This commit is contained in:
Yicheng Qin 2015-03-05 12:46:31 -08:00
parent eec52738d8
commit 3cffc910de
2 changed files with 31 additions and 4 deletions

View File

@ -33,10 +33,24 @@ func main() {
} }
defer c.Terminate() defer c.Terminate()
stressers := make([]Stresser, len(c.ClientURLs))
for i, u := range c.ClientURLs {
s := &stresser{
Endpoint: u,
N: 200,
}
go s.Stress()
stressers[i] = s
}
t := &tester{ t := &tester{
failures: []failure{newFailureBase(), newFailureKillAll()}, failures: []failure{newFailureBase(), newFailureKillAll()},
cluster: c, cluster: c,
limit: *limit, limit: *limit,
} }
t.runLoop() t.runLoop()
for _, s := range stressers {
s.Cancel()
}
} }

View File

@ -1,6 +1,8 @@
package main package main
import ( import (
"net"
"net/http"
"sync" "sync"
"time" "time"
@ -19,9 +21,11 @@ type Stresser interface {
type stresser struct { type stresser struct {
Endpoint string Endpoint string
SuffexRange int // TODO: not implemented
SuffixRange int
N int N int
// TODO: not implemented
Interval time.Duration Interval time.Duration
mu sync.Mutex mu sync.Mutex
@ -32,7 +36,16 @@ type stresser struct {
} }
func (s *stresser) Stress() error { func (s *stresser) Stress() error {
cfg := client.Config{Endpoints: []string{s.Endpoint}} cfg := client.Config{
Endpoints: []string{s.Endpoint},
Transport: &http.Transport{
Dial: (&net.Dialer{
Timeout: time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
MaxIdleConnsPerHost: s.N,
},
}
c, err := client.New(cfg) c, err := client.New(cfg)
if err != nil { if err != nil {
return err return err