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()
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{
failures: []failure{newFailureBase(), newFailureKillAll()},
cluster: c,
limit: *limit,
}
t.runLoop()
for _, s := range stressers {
s.Cancel()
}
}

View File

@ -1,6 +1,8 @@
package main
import (
"net"
"net/http"
"sync"
"time"
@ -18,10 +20,12 @@ type Stresser interface {
}
type stresser struct {
Endpoint string
SuffexRange int
Endpoint string
// TODO: not implemented
SuffixRange int
N int
N int
// TODO: not implemented
Interval time.Duration
mu sync.Mutex
@ -32,7 +36,16 @@ type stresser struct {
}
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)
if err != nil {
return err