fix golint failures of test/e2e_node/services

k3s-v1.15.3
SataQiu 2019-05-15 15:37:21 +08:00
parent b066e0d783
commit 7fa953fcb5
6 changed files with 14 additions and 15 deletions

View File

@ -613,5 +613,4 @@ test/e2e_kubeadm
test/e2e_node test/e2e_node
test/e2e_node/remote test/e2e_node/remote
test/e2e_node/runner/remote test/e2e_node/runner/remote
test/e2e_node/services
test/utils test/utils

View File

@ -90,6 +90,7 @@ func (a *APIServer) Stop() error {
const apiserverName = "apiserver" const apiserverName = "apiserver"
// Name returns the name of APIServer.
func (a *APIServer) Name() string { func (a *APIServer) Name() string {
return apiserverName return apiserverName
} }

View File

@ -60,7 +60,7 @@ func (es *e2eServices) start(t *testing.T) error {
if err != nil { if err != nil {
return err return err
} }
err = es.startApiServer(es.etcdStorage) err = es.startAPIServer(es.etcdStorage)
if err != nil { if err != nil {
return err return err
} }
@ -116,8 +116,8 @@ func (es *e2eServices) startEtcd(t *testing.T) error {
return nil return nil
} }
// startApiServer starts the embedded API server or returns an error. // startAPIServer starts the embedded API server or returns an error.
func (es *e2eServices) startApiServer(etcdStorage *storagebackend.Config) error { func (es *e2eServices) startAPIServer(etcdStorage *storagebackend.Config) error {
klog.Info("Starting API server") klog.Info("Starting API server")
es.apiServer = NewAPIServer(*etcdStorage) es.apiServer = NewAPIServer(*etcdStorage)
return es.apiServer.Start() return es.apiServer.Start()

View File

@ -91,8 +91,9 @@ func RunKubelet() {
const ( const (
// Ports of different e2e services. // Ports of different e2e services.
kubeletPort = "10250" kubeletPort = "10250"
kubeletReadOnlyPort = "10255" kubeletReadOnlyPort = "10255"
// KubeletRootDirectory specifies the directory where the kubelet runtime information is stored.
KubeletRootDirectory = "/var/lib/kubelet" KubeletRootDirectory = "/var/lib/kubelet"
// Health check url of kubelet // Health check url of kubelet
kubeletHealthCheckURL = "http://127.0.0.1:" + kubeletReadOnlyPort + "/healthz" kubeletHealthCheckURL = "http://127.0.0.1:" + kubeletReadOnlyPort + "/healthz"
@ -258,7 +259,7 @@ func (e *E2EServices) startKubelet() (*server, error) {
cmdArgs = append(cmdArgs, cmdArgs = append(cmdArgs,
"--kubeconfig", kubeconfigPath, "--kubeconfig", kubeconfigPath,
"--root-dir", KubeletRootDirectory, "--root-dir", KubeletRootDirectory,
"--v", LOG_VERBOSITY_LEVEL, "--logtostderr", "--v", LogVerbosityLevel, "--logtostderr",
"--allow-privileged=true", "--allow-privileged=true",
) )
@ -412,9 +413,8 @@ func createRootDirectory(path string) error {
if _, err := os.Stat(path); err != nil { if _, err := os.Stat(path); err != nil {
if os.IsNotExist(err) { if os.IsNotExist(err) {
return os.MkdirAll(path, os.FileMode(0755)) return os.MkdirAll(path, os.FileMode(0755))
} else {
return err
} }
return err
} }
return nil return nil
} }

View File

@ -106,7 +106,7 @@ func (s *server) start() error {
var stopRestartingCh, ackStopRestartingCh chan bool var stopRestartingCh, ackStopRestartingCh chan bool
if s.restartOnExit { if s.restartOnExit {
if len(s.healthCheckUrls) == 0 { if len(s.healthCheckUrls) == 0 {
return fmt.Errorf("Tried to start %s which has s.restartOnExit == true, but no health check urls provided.", s) return fmt.Errorf("tried to start %s which has s.restartOnExit == true, but no health check urls provided", s)
} }
stopRestartingCh = make(chan bool) stopRestartingCh = make(chan bool)
@ -124,11 +124,10 @@ func (s *server) start() error {
outPath := path.Join(framework.TestContext.ReportDir, s.outFilename) outPath := path.Join(framework.TestContext.ReportDir, s.outFilename)
outfile, err := os.Create(outPath) outfile, err := os.Create(outPath)
if err != nil { if err != nil {
errCh <- fmt.Errorf("failed to create file %q for `%s` %v.", outPath, s, err) errCh <- fmt.Errorf("failed to create file %q for `%s` %v", outPath, s, err)
return return
} else {
klog.Infof("Output file for server %q: %v", s.name, outfile.Name())
} }
klog.Infof("Output file for server %q: %v", s.name, outfile.Name())
defer outfile.Close() defer outfile.Close()
defer outfile.Sync() defer outfile.Sync()

View File

@ -121,8 +121,8 @@ func RunE2EServices(t *testing.T) {
const ( const (
// services.log is the combined log of all services // services.log is the combined log of all services
servicesLogFile = "services.log" servicesLogFile = "services.log"
// LOG_VERBOSITY_LEVEL is consistent with the level used in a cluster e2e test. // LogVerbosityLevel is consistent with the level used in a cluster e2e test.
LOG_VERBOSITY_LEVEL = "4" LogVerbosityLevel = "4"
) )
// startInternalServices starts the internal services in a separate process. // startInternalServices starts the internal services in a separate process.