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()
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -18,10 +20,12 @@ 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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user