mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
tools/etcd-tester: use stresser
This commit is contained in:
parent
eec52738d8
commit
3cffc910de
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user