mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
tests/e2e: implement EtcdProcess GoFailClientTimeout
Signed-off-by: Ivan Valdes <ivan@vald.es>
This commit is contained in:
parent
6affeed9fd
commit
ec4128af69
@ -105,6 +105,7 @@ type etcdProcessClusterConfig struct {
|
||||
dataDirPath string
|
||||
keepDataDir bool
|
||||
goFailEnabled bool
|
||||
goFailClientTimeout time.Duration
|
||||
peerProxy bool
|
||||
envVars map[string]string
|
||||
|
||||
@ -361,6 +362,7 @@ func (cfg *etcdProcessClusterConfig) etcdServerProcessConfigs() []*etcdServerPro
|
||||
initialToken: cfg.initialToken,
|
||||
clientHttpUrl: clientHttpUrl,
|
||||
goFailPort: gofailPort,
|
||||
goFailClientTimeout: cfg.goFailClientTimeout,
|
||||
proxy: proxyCfg,
|
||||
}
|
||||
}
|
||||
|
@ -94,6 +94,7 @@ type etcdServerProcessConfig struct {
|
||||
|
||||
proxy *proxy.ServerConfig
|
||||
goFailPort int
|
||||
goFailClientTimeout time.Duration
|
||||
}
|
||||
|
||||
func newEtcdServerProcess(cfg *etcdServerProcessConfig) (*etcdServerProcess, error) {
|
||||
@ -107,8 +108,12 @@ func newEtcdServerProcess(cfg *etcdServerProcessConfig) (*etcdServerProcess, err
|
||||
}
|
||||
ep := &etcdServerProcess{cfg: cfg, donec: make(chan struct{})}
|
||||
if cfg.goFailPort != 0 {
|
||||
ep.failpoints = &BinaryFailpoints{member: ep}
|
||||
ep.failpoints = &BinaryFailpoints{
|
||||
member: ep,
|
||||
clientTimeout: cfg.goFailClientTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
return ep, nil
|
||||
}
|
||||
|
||||
@ -232,6 +237,7 @@ func (ep *etcdServerProcess) Etcdctl(connType clientConnType, isAutoTLS, v2 bool
|
||||
type BinaryFailpoints struct {
|
||||
member etcdProcess
|
||||
availableCache map[string]string
|
||||
clientTimeout time.Duration
|
||||
}
|
||||
|
||||
func (f *BinaryFailpoints) SetupEnv(failpoint, payload string) error {
|
||||
@ -253,6 +259,12 @@ func (f *BinaryFailpoints) SetupHTTP(ctx context.Context, failpoint, payload str
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
httpClient := http.Client{
|
||||
Timeout: 1 * time.Second,
|
||||
}
|
||||
if f.clientTimeout != 0 {
|
||||
httpClient.Timeout = f.clientTimeout
|
||||
}
|
||||
resp, err := httpClient.Do(r)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -275,6 +287,12 @@ func (f *BinaryFailpoints) DeactivateHTTP(ctx context.Context, failpoint string)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
httpClient := http.Client{
|
||||
Timeout: 1 * time.Second,
|
||||
}
|
||||
if f.clientTimeout != 0 {
|
||||
httpClient.Timeout = f.clientTimeout
|
||||
}
|
||||
resp, err := httpClient.Do(r)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -286,10 +304,6 @@ func (f *BinaryFailpoints) DeactivateHTTP(ctx context.Context, failpoint string)
|
||||
return nil
|
||||
}
|
||||
|
||||
var httpClient = http.Client{
|
||||
Timeout: 1 * time.Second,
|
||||
}
|
||||
|
||||
func (f *BinaryFailpoints) Enabled() bool {
|
||||
_, err := failpoints(f.member)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user