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.5] Implement etcd process go fail client timeout #17427

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
44 changes: 23 additions & 21 deletions tests/framework/e2e/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,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 @@ -400,21 +401,22 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfigs(tb testing.TB) []*
}

etcdCfgs[i] = &EtcdServerProcessConfig{
lg: lg,
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,
lg: lg,
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
31 changes: 22 additions & 9 deletions tests/framework/e2e/etcd_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ type EtcdServerProcessConfig struct {
Murl string
ClientHttpUrl string

InitialToken string
InitialCluster string
GoFailPort int
Proxy *proxy.ServerConfig
InitialToken string
InitialCluster string
GoFailPort int
GoFailClientTimeout time.Duration
Proxy *proxy.ServerConfig
}

func NewEtcdServerProcess(cfg *EtcdServerProcessConfig) (*EtcdServerProcess, error) {
Expand All @@ -111,7 +112,10 @@ 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 @@ -258,6 +262,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 @@ -279,6 +284,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 @@ -301,6 +312,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 @@ -312,10 +329,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