diff --git a/go/test/endtoend/cluster/mysqlctld_process.go b/go/test/endtoend/cluster/mysqlctld_process.go index 60d30bc6cc0..08409c1246d 100644 --- a/go/test/endtoend/cluster/mysqlctld_process.go +++ b/go/test/endtoend/cluster/mysqlctld_process.go @@ -92,7 +92,15 @@ func (mysqlctld *MysqlctldProcess) Start() error { "--init_db_sql_file", mysqlctld.InitDBFile) } - errFile, _ := os.Create(path.Join(mysqlctld.LogDirectory, "mysqlctld-stderr.txt")) + err := os.MkdirAll(mysqlctld.LogDirectory, 0755) + if err != nil { + log.Errorf("Failed to create directory for mysqlctld logs: %v", err) + return err + } + errFile, err := os.Create(path.Join(mysqlctld.LogDirectory, "mysqlctld-stderr.txt")) + if err != nil { + log.Errorf("Failed to create directory for mysqlctld stderr: %v", err) + } tempProcess.Stderr = errFile tempProcess.Env = append(tempProcess.Env, os.Environ()...) @@ -103,7 +111,7 @@ func (mysqlctld *MysqlctldProcess) Start() error { log.Infof("%v", strings.Join(tempProcess.Args, " ")) - err := tempProcess.Start() + err = tempProcess.Start() if err != nil { return err } diff --git a/go/test/endtoend/cluster/topo_process.go b/go/test/endtoend/cluster/topo_process.go index 45a2e6586fa..776ed7da27e 100644 --- a/go/test/endtoend/cluster/topo_process.go +++ b/go/test/endtoend/cluster/topo_process.go @@ -145,10 +145,10 @@ func (topo *TopoProcess) SetupEtcd() (err error) { // SetupZookeeper spawns a new zookeeper topo service and initializes it with the defaults. // The service is kept running in the background until TearDown() is called. -func (topo *TopoProcess) SetupZookeeper(cluster *LocalProcessCluster) (err error) { +func (topo *TopoProcess) SetupZookeeper(cluster *LocalProcessCluster) error { host, err := os.Hostname() if err != nil { - return + return err } topo.ZKPorts = fmt.Sprintf("%d:%d:%d", cluster.GetAndReservePort(), cluster.GetAndReservePort(), topo.Port) @@ -160,16 +160,21 @@ func (topo *TopoProcess) SetupZookeeper(cluster *LocalProcessCluster) (err error "init", ) - errFile, _ := os.Create(path.Join(topo.DataDirectory, "topo-stderr.txt")) + err = os.MkdirAll(topo.LogDirectory, 0755) + if err != nil { + log.Errorf("Failed to create log directory for zookeeper: %v", err) + return err + } + errFile, err := os.Create(path.Join(topo.LogDirectory, "topo-stderr.txt")) + if err != nil { + log.Errorf("Failed to create file for zookeeper stderr: %v", err) + return err + } topo.proc.Stderr = errFile topo.proc.Env = append(topo.proc.Env, os.Environ()...) log.Infof("Starting zookeeper with args %v", strings.Join(topo.proc.Args, " ")) - err = topo.proc.Run() - if err != nil { - return - } - return + return topo.proc.Run() } // ConsulConfigs are the configurations that are added the config files which are used by consul @@ -193,13 +198,25 @@ type PortsInfo struct { func (topo *TopoProcess) SetupConsul(cluster *LocalProcessCluster) (err error) { topo.VerifyURL = fmt.Sprintf("http://%s:%d/v1/kv/?keys", topo.Host, topo.Port) - _ = os.MkdirAll(topo.LogDirectory, os.ModePerm) - _ = os.MkdirAll(topo.DataDirectory, os.ModePerm) + err = os.MkdirAll(topo.LogDirectory, os.ModePerm) + if err != nil { + log.Errorf("Failed to create directory for consul logs: %v", err) + return + } + err = os.MkdirAll(topo.DataDirectory, os.ModePerm) + if err != nil { + log.Errorf("Failed to create directory for consul data: %v", err) + return + } configFile := path.Join(os.Getenv("VTDATAROOT"), "consul.json") logFile := path.Join(topo.LogDirectory, "/consul.log") - _, _ = os.Create(logFile) + _, err = os.Create(logFile) + if err != nil { + log.Errorf("Failed to create file for consul logs: %v", err) + return + } var config []byte configs := ConsulConfigs{ @@ -233,7 +250,11 @@ func (topo *TopoProcess) SetupConsul(cluster *LocalProcessCluster) (err error) { "-config-file", configFile, ) - errFile, _ := os.Create(path.Join(topo.DataDirectory, "topo-stderr.txt")) + errFile, err := os.Create(path.Join(topo.LogDirectory, "topo-stderr.txt")) + if err != nil { + log.Errorf("Failed to create file for consul stderr: %v", err) + return + } topo.proc.Stderr = errFile topo.proc.Env = append(topo.proc.Env, os.Environ()...) diff --git a/go/test/endtoend/cluster/vtctld_process.go b/go/test/endtoend/cluster/vtctld_process.go index d0b2e5ab93e..d87427af9b9 100644 --- a/go/test/endtoend/cluster/vtctld_process.go +++ b/go/test/endtoend/cluster/vtctld_process.go @@ -79,7 +79,16 @@ func (vtctld *VtctldProcess) Setup(cell string, extraArgs ...string) (err error) } vtctld.proc.Args = append(vtctld.proc.Args, extraArgs...) - errFile, _ := os.Create(path.Join(vtctld.LogDir, "vtctld-stderr.txt")) + err = os.MkdirAll(vtctld.LogDir, 0755) + if err != nil { + log.Errorf("cannot create log directory for vtctld: %v", err) + return err + } + errFile, err := os.Create(path.Join(vtctld.LogDir, "vtctld-stderr.txt")) + if err != nil { + log.Errorf("cannot create error log file for vtctld: %v", err) + return err + } vtctld.proc.Stderr = errFile vtctld.ErrorLog = errFile.Name() diff --git a/go/test/endtoend/cluster/vtgate_process.go b/go/test/endtoend/cluster/vtgate_process.go index ab82a32f651..d1877fb89bb 100644 --- a/go/test/endtoend/cluster/vtgate_process.go +++ b/go/test/endtoend/cluster/vtgate_process.go @@ -130,7 +130,11 @@ func (vtgate *VtgateProcess) Setup() (err error) { vtgate.proc.Args = append(vtgate.proc.Args, vtgate.ExtraArgs...) - errFile, _ := os.Create(path.Join(vtgate.LogDir, "vtgate-stderr.txt")) + errFile, err := os.Create(path.Join(vtgate.LogDir, "vtgate-stderr.txt")) + if err != nil { + log.Errorf("cannot create error log file for vtgate: %v", err) + return err + } vtgate.proc.Stderr = errFile vtgate.proc.Env = append(vtgate.proc.Env, os.Environ()...) diff --git a/go/test/endtoend/cluster/vtorc_process.go b/go/test/endtoend/cluster/vtorc_process.go index f80690d8d60..25bbb74c36c 100644 --- a/go/test/endtoend/cluster/vtorc_process.go +++ b/go/test/endtoend/cluster/vtorc_process.go @@ -86,7 +86,16 @@ func (orc *VTOrcProcess) Setup() (err error) { // create the configuration file timeNow := time.Now().UnixNano() - configFile, _ := os.Create(path.Join(orc.LogDir, fmt.Sprintf("orc-config-%d.json", timeNow))) + err = os.MkdirAll(orc.LogDir, 0755) + if err != nil { + log.Errorf("cannot create log directory for vtorc: %v", err) + return err + } + configFile, err := os.Create(path.Join(orc.LogDir, fmt.Sprintf("orc-config-%d.json", timeNow))) + if err != nil { + log.Errorf("cannot create config file for vtorc: %v", err) + return err + } orc.ConfigPath = configFile.Name() // Add the default configurations and print them out @@ -135,7 +144,11 @@ func (orc *VTOrcProcess) Setup() (err error) { if orc.LogFileName == "" { orc.LogFileName = fmt.Sprintf("orc-stderr-%d.txt", timeNow) } - errFile, _ := os.Create(path.Join(orc.LogDir, orc.LogFileName)) + errFile, err := os.Create(path.Join(orc.LogDir, orc.LogFileName)) + if err != nil { + log.Errorf("cannot create error log file for vtorc: %v", err) + return err + } orc.proc.Stderr = errFile orc.proc.Env = append(orc.proc.Env, os.Environ()...) diff --git a/go/test/endtoend/recovery/pitr/binlog_server.go b/go/test/endtoend/recovery/pitr/binlog_server.go index 764af2b57cf..3b78b0d4ad7 100644 --- a/go/test/endtoend/recovery/pitr/binlog_server.go +++ b/go/test/endtoend/recovery/pitr/binlog_server.go @@ -93,14 +93,18 @@ func (bs *binLogServer) start(source mysqlSource) error { bs.proc.Args = append(bs.proc.Args, fmt.Sprintf("-ripple_master_password=%s", source.password)) } - errFile, _ := os.Create(path.Join(bs.dataDirectory, "log.txt")) + errFile, err := os.Create(path.Join(bs.dataDirectory, "log.txt")) + if err != nil { + log.Errorf("cannot create error log file for binlog server: %v", err) + return err + } bs.proc.Stderr = errFile bs.proc.Env = append(bs.proc.Env, os.Environ()...) log.Infof("Running binlog server with command: %v", strings.Join(bs.proc.Args, " ")) - err := bs.proc.Start() + err = bs.proc.Start() if err != nil { return err }