Skip to content

Commit

Permalink
dont fail with Failf(), use Errorf() instead; break loop when first c…
Browse files Browse the repository at this point in the history
…oncerning log is found
  • Loading branch information
Tofel committed May 23, 2024
1 parent 5db47b6 commit ca8602c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
10 changes: 7 additions & 3 deletions integration-tests/docker/test_env/test_env_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,28 +306,32 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) {

// we cannot do parallel processing here, because ProcessContainerLogs() locks a mutex that controls whether
// new logs can be added to the log stream, so parallel processing would get stuck on waiting for it to be unlocked
LogScanningLoop:
for i := 0; i < b.clNodesCount; i++ {
// ignore count return, because we are only interested in the error
_, err := logProcessor.ProcessContainerLogs(b.te.ClCluster.Nodes[i].ContainerName, processFn)
if err != nil && !strings.Contains(err.Error(), testreporters.MultipleLogsAtLogLevelErr) && !strings.Contains(err.Error(), testreporters.OneLogAtLogLevelErr) {
b.l.Error().Err(err).Msg("Error processing logs")
return
b.l.Error().Err(err).Msg("Error processing CL node logs")
continue
} else if err != nil && (strings.Contains(err.Error(), testreporters.MultipleLogsAtLogLevelErr) || strings.Contains(err.Error(), testreporters.OneLogAtLogLevelErr)) {
flushLogStream = true
b.t.Fatalf("Found a concerning log in Chainklink Node logs: %v", err)
b.t.Errorf("Found a concerning log in Chainklink Node logs: %v", err)
break LogScanningLoop
}
}
b.l.Info().Msg("Finished scanning Chainlink Node logs for concerning errors")
}

if flushLogStream {
b.l.Info().Msg("Flushing LogStream logs")
// we can't do much if this fails, so we just log the error in LogStream
if err := b.te.LogStream.FlushAndShutdown(); err != nil {
b.l.Error().Err(err).Msg("Error flushing and shutting down LogStream")
}
b.te.LogStream.PrintLogTargetsLocations()
b.te.LogStream.SaveLogLocationInTestSummary()
}
b.l.Info().Msg("Finished shutting down LogStream")
})
} else {
b.l.Warn().Msg("LogStream won't be cleaned up, because test instance is not set or cleanup type is not standard")
Expand Down
25 changes: 25 additions & 0 deletions integration-tests/utils/slice.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package utils

func DivideSlice[T any](slice []T, parts int) [][]T {
var divided [][]T
if parts == 1 {
return [][]T{slice}
}

sliceLength := len(slice)
baseSize := sliceLength / parts
remainder := sliceLength % parts

start := 0
for i := 0; i < parts; i++ {
end := start + baseSize
if i < remainder { // Distribute the remainder among the first slices
end++
}

divided = append(divided, slice[start:end])
start = end
}

return divided
}

0 comments on commit ca8602c

Please sign in to comment.