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

tests/framework: address golangci var-naming issues #17651

Merged
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
12 changes: 6 additions & 6 deletions tests/e2e/cmux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestConnectionMultiplexing(t *testing.T) {
ctx := context.Background()
cfg := e2e.NewConfig(e2e.WithClusterSize(1))
cfg.Client.ConnectionType = tc.serverTLS
cfg.ClientHttpSeparate = tc.separateHTTPPort
cfg.ClientHTTPSeparate = tc.separateHTTPPort
clus, err := e2e.NewEtcdProcessCluster(ctx, t, e2e.WithConfig(cfg))
require.NoError(t, err)
defer clus.Close()
Expand Down Expand Up @@ -146,7 +146,7 @@ func fetchGRPCGateway(endpoint string, httpVersion string, connType e2e.ClientCo
if err != nil {
return err
}
req := e2e.CURLReq{Endpoint: "/v3/kv/range", Value: string(rangeData), Timeout: 5, HttpVersion: httpVersion}
req := e2e.CURLReq{Endpoint: "/v3/kv/range", Value: string(rangeData), Timeout: 5, HTTPVersion: httpVersion}
respData, err := curl(endpoint, "POST", req, connType)
if err != nil {
return err
Expand Down Expand Up @@ -178,7 +178,7 @@ func fetchMetrics(t *testing.T, endpoint string, httpVersion string, connType e2
tmpDir := t.TempDir()
metricFile := filepath.Join(tmpDir, "metrics")

req := e2e.CURLReq{Endpoint: "/metrics", Timeout: 5, HttpVersion: httpVersion, OutputFile: metricFile}
req := e2e.CURLReq{Endpoint: "/metrics", Timeout: 5, HTTPVersion: httpVersion, OutputFile: metricFile}
if _, err := curl(endpoint, "GET", req, connType); err != nil {
return err
}
Expand All @@ -195,7 +195,7 @@ func fetchMetrics(t *testing.T, endpoint string, httpVersion string, connType e2
}

func fetchVersion(endpoint string, httpVersion string, connType e2e.ClientConnType) error {
req := e2e.CURLReq{Endpoint: "/version", Timeout: 5, HttpVersion: httpVersion}
req := e2e.CURLReq{Endpoint: "/version", Timeout: 5, HTTPVersion: httpVersion}
respData, err := curl(endpoint, "GET", req, connType)
if err != nil {
return err
Expand All @@ -205,7 +205,7 @@ func fetchVersion(endpoint string, httpVersion string, connType e2e.ClientConnTy
}

func fetchHealth(endpoint string, httpVersion string, connType e2e.ClientConnType) error {
req := e2e.CURLReq{Endpoint: "/health", Timeout: 5, HttpVersion: httpVersion}
req := e2e.CURLReq{Endpoint: "/health", Timeout: 5, HTTPVersion: httpVersion}
respData, err := curl(endpoint, "GET", req, connType)
if err != nil {
return err
Expand All @@ -215,7 +215,7 @@ func fetchHealth(endpoint string, httpVersion string, connType e2e.ClientConnTyp
}

func fetchDebugVars(endpoint string, httpVersion string, connType e2e.ClientConnType) error {
req := e2e.CURLReq{Endpoint: "/debug/vars", Timeout: 5, HttpVersion: httpVersion}
req := e2e.CURLReq{Endpoint: "/debug/vars", Timeout: 5, HTTPVersion: httpVersion}
respData, err := curl(endpoint, "GET", req, connType)
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/watch_delay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestWatchDelayForPeriodicProgressNotification(t *testing.T) {
cfg.ClusterSize = 1
cfg.ServerConfig.ExperimentalWatchProgressNotifyInterval = watchResponsePeriod
cfg.Client = tc.client
cfg.ClientHttpSeparate = tc.clientHTTPSeparate
cfg.ClientHTTPSeparate = tc.clientHTTPSeparate
t.Run(tc.name, func(t *testing.T) {
clus, err := e2e.NewEtcdProcessCluster(context.Background(), t, e2e.WithConfig(cfg))
require.NoError(t, err)
Expand All @@ -114,7 +114,7 @@ func TestWatchDelayForManualProgressNotification(t *testing.T) {
cfg := e2e.DefaultConfig()
cfg.ClusterSize = 1
cfg.Client = tc.client
cfg.ClientHttpSeparate = tc.clientHTTPSeparate
cfg.ClientHTTPSeparate = tc.clientHTTPSeparate
t.Run(tc.name, func(t *testing.T) {
clus, err := e2e.NewEtcdProcessCluster(context.Background(), t, e2e.WithConfig(cfg))
require.NoError(t, err)
Expand Down Expand Up @@ -151,7 +151,7 @@ func TestWatchDelayForEvent(t *testing.T) {
cfg := e2e.DefaultConfig()
cfg.ClusterSize = 1
cfg.Client = tc.client
cfg.ClientHttpSeparate = tc.clientHTTPSeparate
cfg.ClientHTTPSeparate = tc.clientHTTPSeparate
t.Run(tc.name, func(t *testing.T) {
clus, err := e2e.NewEtcdProcessCluster(context.Background(), t, e2e.WithConfig(cfg))
require.NoError(t, err)
Expand Down
36 changes: 18 additions & 18 deletions tests/framework/e2e/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ type EtcdProcessClusterConfig struct {
BaseClientScheme string
MetricsURLScheme string
Client ClientConfig
ClientHttpSeparate bool
ClientHTTPSeparate bool
IsPeerTLS bool
IsPeerAutoTLS bool
CN bool
Expand Down Expand Up @@ -486,7 +486,7 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in
peerPort := port + 1
metricsPort := port + 2
peer2Port := port + 3
clientHttpPort := port + 4
clientHTTPPort := port + 4

if cfg.Client.ConnectionType == ClientTLSAndNonTLS {
curl = clientURL(cfg.ClientScheme(), clientPort, ClientNonTLS)
Expand All @@ -496,18 +496,18 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in
curls = []string{curl}
}

peerListenUrl := url.URL{Scheme: cfg.PeerScheme(), Host: fmt.Sprintf("localhost:%d", peerPort)}
peerAdvertiseUrl := url.URL{Scheme: cfg.PeerScheme(), Host: fmt.Sprintf("localhost:%d", peerPort)}
peerListenURL := url.URL{Scheme: cfg.PeerScheme(), Host: fmt.Sprintf("localhost:%d", peerPort)}
peerAdvertiseURL := url.URL{Scheme: cfg.PeerScheme(), Host: fmt.Sprintf("localhost:%d", peerPort)}
var proxyCfg *proxy.ServerConfig
if cfg.PeerProxy {
if !cfg.IsPeerTLS {
panic("Can't use peer proxy without peer TLS as it can result in malformed packets")
}
peerAdvertiseUrl.Host = fmt.Sprintf("localhost:%d", peer2Port)
peerAdvertiseURL.Host = fmt.Sprintf("localhost:%d", peer2Port)
proxyCfg = &proxy.ServerConfig{
Logger: zap.NewNop(),
To: peerListenUrl,
From: peerAdvertiseUrl,
To: peerListenURL,
From: peerAdvertiseURL,
}
}

Expand All @@ -529,16 +529,16 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in
"--name=" + name,
"--listen-client-urls=" + strings.Join(curls, ","),
"--advertise-client-urls=" + strings.Join(curls, ","),
"--listen-peer-urls=" + peerListenUrl.String(),
"--initial-advertise-peer-urls=" + peerAdvertiseUrl.String(),
"--listen-peer-urls=" + peerListenURL.String(),
"--initial-advertise-peer-urls=" + peerAdvertiseURL.String(),
"--initial-cluster-token=" + cfg.ServerConfig.InitialClusterToken,
"--data-dir", dataDirPath,
"--snapshot-count=" + fmt.Sprintf("%d", cfg.ServerConfig.SnapshotCount),
}
var clientHttpUrl string
if cfg.ClientHttpSeparate {
clientHttpUrl = clientURL(cfg.ClientScheme(), clientHttpPort, cfg.Client.ConnectionType)
args = append(args, "--listen-client-http-urls="+clientHttpUrl)
var clientHTTPURL string
if cfg.ClientHTTPSeparate {
clientHTTPURL = clientURL(cfg.ClientScheme(), clientHTTPPort, cfg.Client.ConnectionType)
args = append(args, "--listen-client-http-urls="+clientHTTPURL)
}

if cfg.ServerConfig.ForceNewCluster {
Expand All @@ -564,7 +564,7 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in
args = append(args, "--listen-metrics-urls="+murl)
}

args = append(args, cfg.TlsArgs()...)
args = append(args, cfg.TLSArgs()...)

if cfg.Discovery != "" {
args = append(args, "--discovery="+cfg.Discovery)
Expand Down Expand Up @@ -618,14 +618,14 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in
ExecPath: execPath,
Args: args,
EnvVars: envVars,
TlsArgs: cfg.TlsArgs(),
TLSArgs: cfg.TLSArgs(),
Client: cfg.Client,
DataDirPath: dataDirPath,
KeepDataDir: cfg.KeepDataDir,
Name: name,
PeerURL: peerAdvertiseUrl,
PeerURL: peerAdvertiseURL,
ClientURL: curl,
ClientHTTPURL: clientHttpUrl,
ClientHTTPURL: clientHTTPURL,
MetricsURL: murl,
InitialToken: cfg.ServerConfig.InitialClusterToken,
GoFailPort: gofailPort,
Expand Down Expand Up @@ -661,7 +661,7 @@ func clientURL(scheme string, port int, connType ClientConnType) string {
}
}

func (cfg *EtcdProcessClusterConfig) TlsArgs() (args []string) {
func (cfg *EtcdProcessClusterConfig) TLSArgs() (args []string) {
if cfg.Client.ConnectionType != ClientNonTLS {
if cfg.Client.AutoTLS {
args = append(args, "--auto-tls")
Expand Down
16 changes: 8 additions & 8 deletions tests/framework/e2e/cluster_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func newProxyV2Proc(cfg *EtcdServerProcessConfig) *proxyV2Proc {
name: cfg.Name,
lg: cfg.lg,
execPath: cfg.ExecPath,
args: append(args, cfg.TlsArgs...),
args: append(args, cfg.TLSArgs...),
ep: listenAddr,
donec: make(chan struct{}),
},
Expand Down Expand Up @@ -225,27 +225,27 @@ func newProxyV3Proc(cfg *EtcdServerProcessConfig) *proxyV3Proc {
args = append(args, "--metrics-addr", murl)
}
tlsArgs := []string{}
for i := 0; i < len(cfg.TlsArgs); i++ {
switch cfg.TlsArgs[i] {
for i := 0; i < len(cfg.TLSArgs); i++ {
switch cfg.TLSArgs[i] {
case "--cert-file":
tlsArgs = append(tlsArgs, "--cert-file", cfg.TlsArgs[i+1])
tlsArgs = append(tlsArgs, "--cert-file", cfg.TLSArgs[i+1])
i++
case "--key-file":
tlsArgs = append(tlsArgs, "--key-file", cfg.TlsArgs[i+1])
tlsArgs = append(tlsArgs, "--key-file", cfg.TLSArgs[i+1])
i++
case "--trusted-ca-file":
tlsArgs = append(tlsArgs, "--trusted-ca-file", cfg.TlsArgs[i+1])
tlsArgs = append(tlsArgs, "--trusted-ca-file", cfg.TLSArgs[i+1])
i++
case "--auto-tls":
tlsArgs = append(tlsArgs, "--auto-tls", "--insecure-skip-tls-verify")
case "--peer-trusted-ca-file", "--peer-cert-file", "--peer-key-file":
i++ // skip arg
case "--client-cert-auth", "--peer-auto-tls":
default:
tlsArgs = append(tlsArgs, cfg.TlsArgs[i])
tlsArgs = append(tlsArgs, cfg.TLSArgs[i])
}
}
if len(cfg.TlsArgs) > 0 {
if len(cfg.TLSArgs) > 0 {
// Configure certificates for connection proxy ---> server.
// This certificate must NOT have CN set.
tlsArgs = append(tlsArgs,
Expand Down
6 changes: 3 additions & 3 deletions tests/framework/e2e/curl.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type CURLReq struct {
Header string

Ciphers string
HttpVersion string
HTTPVersion string

OutputFile string
}
Expand All @@ -62,8 +62,8 @@ func CURLPrefixArgs(clientURL string, cfg ClientConfig, CN bool, method string,
var (
cmdArgs = []string{"curl"}
)
if req.HttpVersion != "" {
cmdArgs = append(cmdArgs, "--http"+req.HttpVersion)
if req.HTTPVersion != "" {
cmdArgs = append(cmdArgs, "--http"+req.HTTPVersion)
}
if req.IsTLS {
if cfg.ConnectionType != ClientTLSAndNonTLS {
Expand Down
14 changes: 7 additions & 7 deletions tests/framework/e2e/etcd_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type EtcdServerProcessConfig struct {
lg *zap.Logger
ExecPath string
Args []string
TlsArgs []string
TLSArgs []string
EnvVars map[string]string

Client ClientConfig
Expand Down Expand Up @@ -354,12 +354,12 @@ func (f *BinaryFailpoints) SetupEnv(failpoint, payload string) error {

func (f *BinaryFailpoints) SetupHTTP(ctx context.Context, failpoint, payload string) error {
host := fmt.Sprintf("127.0.0.1:%d", f.member.Config().GoFailPort)
failpointUrl := url.URL{
failpointURL := url.URL{
Scheme: "http",
Host: host,
Path: failpoint,
}
r, err := http.NewRequestWithContext(ctx, "PUT", failpointUrl.String(), bytes.NewBuffer([]byte(payload)))
r, err := http.NewRequestWithContext(ctx, "PUT", failpointURL.String(), bytes.NewBuffer([]byte(payload)))
if err != nil {
return err
}
Expand All @@ -382,12 +382,12 @@ func (f *BinaryFailpoints) SetupHTTP(ctx context.Context, failpoint, payload str

func (f *BinaryFailpoints) DeactivateHTTP(ctx context.Context, failpoint string) error {
host := fmt.Sprintf("127.0.0.1:%d", f.member.Config().GoFailPort)
failpointUrl := url.URL{
failpointURL := url.URL{
Scheme: "http",
Host: host,
Path: failpoint,
}
r, err := http.NewRequestWithContext(ctx, "DELETE", failpointUrl.String(), nil)
r, err := http.NewRequestWithContext(ctx, "DELETE", failpointURL.String(), nil)
if err != nil {
return err
}
Expand Down Expand Up @@ -439,11 +439,11 @@ func failpoints(member EtcdProcess) (map[string]string, error) {

func fetchFailpointsBody(member EtcdProcess) (io.ReadCloser, error) {
address := fmt.Sprintf("127.0.0.1:%d", member.Config().GoFailPort)
failpointUrl := url.URL{
failpointURL := url.URL{
Scheme: "http",
Host: address,
}
resp, err := http.Get(failpointUrl.String())
resp, err := http.Get(failpointURL.String())
if err != nil {
return nil, err
}
Expand Down
Loading
Loading