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 inconsistent test failure #618

Merged
merged 1 commit into from
Oct 18, 2024
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
13 changes: 6 additions & 7 deletions logs/stream/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,8 @@ func TestAnalyzeStreamInGroups(t *testing.T) {
for _, pair := range streamTests {
server := state.MakeServer(config.ServerConfig{}, false)
TransientLogState, logFile, tooFreshLogLines, err := stream.AnalyzeStreamInGroups(pair.logLines, now, server, &util.Logger{Destination: log.New(os.Stderr, "", log.LstdFlags)})
logFileContent := ""
for idx, logLine := range logFile.LogLines {
logFileContent += logLine.Content
logFile.LogLines[idx].Content = ""
}

TransientLogState.CollectedAt = time.Time{} // Avoid comparing against time.Now()
logFile.UUID = uuid.UUID{} // Avoid comparing against a generated UUID

cfg := pretty.CompareConfig
cfg.SkipZeroFields = true

Expand All @@ -383,6 +376,12 @@ func TestAnalyzeStreamInGroups(t *testing.T) {
sort.SliceStable(logFile.LogLines, func(i, j int) bool {
return logFile.LogLines[i].ByteStart < logFile.LogLines[j].ByteStart
})
logFileContent := ""
for idx, logLine := range logFile.LogLines {
logFileContent += logLine.Content
logFile.LogLines[idx].Content = ""
}

if diff := cfg.Compare(pair.logFile, logFile); diff != "" {
t.Errorf("For %v: log file diff: (-want +got)\n%s", pair.logFile, diff)
}
Expand Down
Loading