Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.4] backport EtcdProcess GoFailClientTimeout #17432

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions tests/e2e/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,13 @@ type etcdProcessCluster struct {
}

type etcdProcessClusterConfig struct {
execPath string
dataDirPath string
keepDataDir bool
goFailEnabled bool
peerProxy bool
envVars map[string]string
execPath string
dataDirPath string
keepDataDir bool
goFailEnabled bool
goFailClientTimeout time.Duration
peerProxy bool
envVars map[string]string

clusterSize int

Expand Down Expand Up @@ -348,20 +349,21 @@ func (cfg *etcdProcessClusterConfig) etcdServerProcessConfigs() []*etcdServerPro
}

etcdCfgs[i] = &etcdServerProcessConfig{
execPath: cfg.execPath,
args: args,
envVars: envVars,
tlsArgs: cfg.tlsArgs(),
dataDirPath: dataDirPath,
keepDataDir: cfg.keepDataDir,
name: name,
purl: peerAdvertiseUrl,
acurl: curl,
murl: murl,
initialToken: cfg.initialToken,
clientHttpUrl: clientHttpUrl,
goFailPort: gofailPort,
proxy: proxyCfg,
execPath: cfg.execPath,
args: args,
envVars: envVars,
tlsArgs: cfg.tlsArgs(),
dataDirPath: dataDirPath,
keepDataDir: cfg.keepDataDir,
name: name,
purl: peerAdvertiseUrl,
acurl: curl,
murl: murl,
initialToken: cfg.initialToken,
clientHttpUrl: clientHttpUrl,
goFailPort: gofailPort,
goFailClientTimeout: cfg.goFailClientTimeout,
proxy: proxyCfg,
}
}

Expand Down
28 changes: 21 additions & 7 deletions tests/e2e/etcd_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ type etcdServerProcessConfig struct {
initialToken string
initialCluster string

proxy *proxy.ServerConfig
goFailPort int
proxy *proxy.ServerConfig
goFailPort int
goFailClientTimeout time.Duration
}

func newEtcdServerProcess(cfg *etcdServerProcessConfig) (*etcdServerProcess, error) {
Expand All @@ -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
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 {
Expand Down
Loading