Skip to content

Commit

Permalink
Fix path setup
Browse files Browse the repository at this point in the history
We weren't always creating the paths and ignoring the error was hiding
the problem making it really hard to debug.

Signed-off-by: Dirkjan Bussink <[email protected]>
  • Loading branch information
dbussink committed Nov 8, 2023
1 parent b9ecc75 commit 6d01d4b
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 20 deletions.
12 changes: 10 additions & 2 deletions go/test/endtoend/cluster/mysqlctld_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()...)
Expand All @@ -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
}
Expand Down
45 changes: 33 additions & 12 deletions go/test/endtoend/cluster/topo_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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{
Expand Down Expand Up @@ -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()...)
Expand Down
11 changes: 10 additions & 1 deletion go/test/endtoend/cluster/vtctld_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 5 additions & 1 deletion go/test/endtoend/cluster/vtgate_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()...)
Expand Down
17 changes: 15 additions & 2 deletions go/test/endtoend/cluster/vtorc_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()...)
Expand Down
8 changes: 6 additions & 2 deletions go/test/endtoend/recovery/pitr/binlog_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 6d01d4b

Please sign in to comment.