Skip to content

Commit

Permalink
test: Only call Fail() once for all error logs
Browse files Browse the repository at this point in the history
We've recently expanded the fail cases for when different logs are seen
in the cilium-agent logs. However at the same time we also introduced
a behaviour where for every single instance of the failure in the logs,
we will call Fail(). In local CI runs with `--holdEnvironment` this can
lead to a loop where the test is suspended for debugging, the developer
performs ^Z and `fg`, then the same failure prints again, potentially
many times over before the test can finally proceed / clean up.

Tidy it up by detecting any failure of this sort once, then failing out.

Note that the actual failure logs should already be visible earlier in
the test output so this should not hide the failures from the developer.

Signed-off-by: Joe Stringer <joe@cilium.io>
  • Loading branch information
joestringer authored and tgraf committed Apr 28, 2020
1 parent a920f94 commit a4867b8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/helpers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ func CanRunK8sVersion(ciliumVersion, k8sVersionStr string) (bool, error) {
// given log messages contains an entry from the blacklist (map key) AND
// does not contain ignore messages (map value).
func failIfContainsBadLogMsg(logs string, blacklist map[string][]string) {
nFailures := 0
for _, msg := range strings.Split(logs, "\n") {
for fail, ignoreMessages := range blacklist {
if strings.Contains(msg, fail) {
Expand All @@ -479,11 +480,14 @@ func failIfContainsBadLogMsg(logs string, blacklist map[string][]string) {
}
if !ok {
fmt.Fprintf(CheckLogs, "⚠️ Found a %q in logs\n", fail)
Fail(fmt.Sprintf("Found a %q in Cilium Logs", fail))
nFailures++
}
}
}
}
if nFailures > 0 {
Fail(fmt.Sprintf("Found %d Cilium logs matching list of errors that must be investigated", nFailures))
}
}

// RunsOnNetNextOr419Kernel checks whether a test case is running on the net-next
Expand Down

0 comments on commit a4867b8

Please sign in to comment.