Skip to content

Commit

Permalink
feat: print error.log file to see what's going on
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 committed Dec 11, 2023
1 parent df817d1 commit cc14767
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
39 changes: 39 additions & 0 deletions go/test/endtoend/cluster/mysqlctld_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ import (
"os/exec"
"path"
"strings"
"testing"
"time"

"github.com/stretchr/testify/require"

"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/vt/log"
)
Expand Down Expand Up @@ -150,6 +153,42 @@ func (mysqlctld *MysqlctldProcess) CleanupFiles(tabletUID int) {
os.RemoveAll(path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d", tabletUID)))
}

func PrintFiles(t *testing.T, tabletUID int, files ...string) {
dir := path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d", tabletUID))
var directories []string
directories = append(directories, dir)

for len(directories) > 0 {
dir = directories[0]
directories = directories[1:]
entries, err := os.ReadDir(dir)
require.NoError(t, err)
for _, entry := range entries {
name := path.Join(dir, entry.Name())
if entry.IsDir() {
directories = append(directories, name)
continue
}
if len(files) != 0 {
fileFound := false
for _, file := range files {
if strings.EqualFold(entry.Name(), file) {
fileFound = true
break
}
}
if !fileFound {
continue
}
}
res, err := os.ReadFile(name)
require.NoError(t, err)
log.Errorf("READING FILE - %v", name)
log.Errorf("%v", string(res))
}
}
}

// MysqlCtldProcessInstance returns a Mysqlctld handle for mysqlctld process
// configured with the given Config.
func MysqlCtldProcessInstance(tabletUID int, mySQLPort int, tmpDirectory string) *MysqlctldProcess {
Expand Down
1 change: 1 addition & 0 deletions go/test/endtoend/mysqlctld/mysqlctld_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func TestRestart(t *testing.T) {
defer cluster.PanicHandler(t)
err := primaryTablet.MysqlctldProcess.Stop()
require.Nil(t, err)
cluster.PrintFiles(t, primaryTablet.TabletUID, "error.log")
primaryTablet.MysqlctldProcess.CleanupFiles(primaryTablet.TabletUID)
err = primaryTablet.MysqlctldProcess.Start()
require.Nil(t, err)
Expand Down

0 comments on commit cc14767

Please sign in to comment.