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

Fix flaky mysqlctl blackbox test #17387

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions go/vt/logutil/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"io"
"runtime"
"slices"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -246,6 +247,12 @@ func (ml *MemoryLogger) Clear() {
ml.mu.Unlock()
}

func (ml *MemoryLogger) LogEvents() []*logutilpb.Event {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, but IMO GetEvents() is a better name. If it's not safe to access Events directly, then it may also make sense to make it private (rename it to events).

ml.mu.Lock()
defer ml.mu.Unlock()
return slices.Clone(ml.Events)
}

// LoggerWriter is an adapter that implements the io.Writer interface.
type LoggerWriter struct {
logger Logger
Expand Down
2 changes: 1 addition & 1 deletion go/vt/mysqlctl/blackbox/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func GetStats(stats *backupstats.FakeStats) StatSummary {

func AssertLogs(t *testing.T, expectedLogs []string, logger *logutil.MemoryLogger) {
for _, log := range expectedLogs {
require.Truef(t, slices.ContainsFunc(logger.Events, func(event *logutilpb.Event) bool {
require.Truef(t, slices.ContainsFunc(logger.LogEvents(), func(event *logutilpb.Event) bool {
return event.GetValue() == log
}), "%s is missing from the logs", log)
}
Expand Down
Loading