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

logictest: improve progress output #72468

Merged
merged 2 commits into from
Jan 27, 2022
Merged
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
16 changes: 9 additions & 7 deletions pkg/sql/logictest/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ type logicTest struct {
// new one, but keep some shared resources across the entire test. An example
// would be an IO directory used throughout the test.
testCleanupFuncs []func()
// progress holds the number of tests executed so far.
// progress holds the number of statements executed so far.
progress int
// failures holds the number of tests failed so far, when
// -try-harder is set.
Expand Down Expand Up @@ -1325,11 +1325,13 @@ func (t *logicTest) close() {
// out emits a message both on stdout and the log files if
// verbose is set.
func (t *logicTest) outf(format string, args ...interface{}) {
if t.verbose {
fmt.Printf(format, args...)
fmt.Println()
log.Infof(context.Background(), format, args...)
if !t.verbose {
return
}
log.Infof(context.Background(), format, args...)
msg := fmt.Sprintf(format, args...)
now := timeutil.Now().Format("15:04:05")
fmt.Printf("[%s] %s\n", now, msg)
}

// setUser sets the DB client to the specified user.
Expand Down Expand Up @@ -3220,7 +3222,7 @@ func (t *logicTest) success(file string) {
now := timeutil.Now()
if now.Sub(t.lastProgress) >= 2*time.Second {
t.lastProgress = now
t.outf("--- progress: %s: %d statements/queries", file, t.progress)
t.outf("--- progress: %s: %d statements", file, t.progress)
}
}

Expand Down Expand Up @@ -3593,7 +3595,7 @@ func RunLogicTestWithDefaultConfig(
now := timeutil.Now()
if now.Sub(progress.lastProgress) >= 2*time.Second {
progress.lastProgress = now
lt.outf("--- total progress: %d statements/queries", progress.total)
lt.outf("--- total progress: %d statements", progress.total)
}
})
}
Expand Down