Skip to content

Commit

Permalink
Fix flaky mysqlctl blackbox test (#17387)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbussink authored Dec 12, 2024
1 parent 69f2f8f commit 45192d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
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 {
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

0 comments on commit 45192d2

Please sign in to comment.