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
|
dataDirPath string
|
||||||
keepDataDir bool
|
keepDataDir bool
|
||||||
goFailEnabled bool
|
goFailEnabled bool
|
||||||
|
goFailClientTimeout time.Duration
|
||||||
peerProxy bool
|
peerProxy bool
|
||||||
envVars map[string]string
|
envVars map[string]string
|
||||||
|
|
||||||
@ -361,6 +362,7 @@ func (cfg *etcdProcessClusterConfig) etcdServerProcessConfigs() []*etcdServerPro
|
|||||||
initialToken: cfg.initialToken,
|
initialToken: cfg.initialToken,
|
||||||
clientHttpUrl: clientHttpUrl,
|
clientHttpUrl: clientHttpUrl,
|
||||||
goFailPort: gofailPort,
|
goFailPort: gofailPort,
|
||||||
|
goFailClientTimeout: cfg.goFailClientTimeout,
|
||||||
proxy: proxyCfg,
|
proxy: proxyCfg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,7 @@ type etcdServerProcessConfig struct {
|
|||||||
|
|
||||||
proxy *proxy.ServerConfig
|
proxy *proxy.ServerConfig
|
||||||
goFailPort int
|
goFailPort int
|
||||||
|
goFailClientTimeout time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func newEtcdServerProcess(cfg *etcdServerProcessConfig) (*etcdServerProcess, error) {
|
func newEtcdServerProcess(cfg *etcdServerProcessConfig) (*etcdServerProcess, error) {
|
||||||
@ -107,8 +108,12 @@ func newEtcdServerProcess(cfg *etcdServerProcessConfig) (*etcdServerProcess, err
|
|||||||
}
|
}
|
||||||
ep := &etcdServerProcess{cfg: cfg, donec: make(chan struct{})}
|
ep := &etcdServerProcess{cfg: cfg, donec: make(chan struct{})}
|
||||||
if cfg.goFailPort != 0 {
|
if cfg.goFailPort != 0 {
|
||||||
ep.failpoints = &BinaryFailpoints{member: ep}
|
ep.failpoints = &BinaryFailpoints{
|
||||||
|
member: ep,
|
||||||
|
clientTimeout: cfg.goFailClientTimeout,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ep, nil
|
return ep, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,6 +237,7 @@ func (ep *etcdServerProcess) Etcdctl(connType clientConnType, isAutoTLS, v2 bool
|
|||||||
type BinaryFailpoints struct {
|
type BinaryFailpoints struct {
|
||||||
member etcdProcess
|
member etcdProcess
|
||||||
availableCache map[string]string
|
availableCache map[string]string
|
||||||
|
clientTimeout time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *BinaryFailpoints) SetupEnv(failpoint, payload string) error {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
httpClient := http.Client{
|
||||||
|
Timeout: 1 * time.Second,
|
||||||
|
}
|
||||||
|
if f.clientTimeout != 0 {
|
||||||
|
httpClient.Timeout = f.clientTimeout
|
||||||
|
}
|
||||||
resp, err := httpClient.Do(r)
|
resp, err := httpClient.Do(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -275,6 +287,12 @@ func (f *BinaryFailpoints) DeactivateHTTP(ctx context.Context, failpoint string)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
httpClient := http.Client{
|
||||||
|
Timeout: 1 * time.Second,
|
||||||
|
}
|
||||||
|
if f.clientTimeout != 0 {
|
||||||
|
httpClient.Timeout = f.clientTimeout
|
||||||
|
}
|
||||||
resp, err := httpClient.Do(r)
|
resp, err := httpClient.Do(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -286,10 +304,6 @@ func (f *BinaryFailpoints) DeactivateHTTP(ctx context.Context, failpoint string)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var httpClient = http.Client{
|
|
||||||
Timeout: 1 * time.Second,
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *BinaryFailpoints) Enabled() bool {
|
func (f *BinaryFailpoints) Enabled() bool {
|
||||||
_, err := failpoints(f.member)
|
_, err := failpoints(f.member)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user