-
Notifications
You must be signed in to change notification settings - Fork 168
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
testiso.go: Add go routine to handle badness #3895
base: main
Are you sure you want to change the base?
Conversation
Skipping CI for Draft Pull Request. |
mantle/platform/qemu.go
Outdated
// failed inside the CheckConsole. The resulting string will | ||
// be a newline-delimited stream of JSON strings, as returned | ||
// by `journalctl -o json`. | ||
func (inst *QemuInstance) CheckConsoleForBadness(ctx context.Context) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like almost the same code as the WaitIgnitionError
function. We don't want to duplicate code, we should probably have a function that deals with the journal processing that can be used in WaitIgnitionError
and CheckConsoleForBadness
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not 💯 % sure about this, but do we want to check the content of the journal or the serial console? AFAIU these are different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct. For now I reverted changes to go back to the initial stages of the first PR related to the same issue. Once work in this PR compiles and works as expected I will request another review if you don't mind :)
ok I think the strategy here should probably be to just call There is precedent for calling coreos-assembler/mantle/cmd/kola/console.go Lines 77 to 81 in 7550a58
So we should be able to do something like: diff --git a/mantle/cmd/kola/testiso.go b/mantle/cmd/kola/testiso.go
index a925d3d25..e2cd761c1 100644
--- a/mantle/cmd/kola/testiso.go
+++ b/mantle/cmd/kola/testiso.go
@@ -729,7 +729,18 @@ func awaitCompletion(ctx context.Context, inst *platform.QemuInstance, outdir st
}
}()
err := <-errchan
- return time.Since(start), err
+ // The test is done so let's record the amount of elapsed time
+ elapsed = time.Since(start)
+ if err == nil; {
+ // No error so far; let's check the console/journal
+ for each of inst.builder.consoleFile and filepath.Join(outdir, "journal.txt") we need to {
+
+ warnOnly, badlines := kola.CheckConsole(readfile, nil)
+ for range badlines
+ do something and set err to !nil if there was badness
+ }
+ }
+ return elapsed, err
}
func printResult(test string, duration time.Duration, err error) bool { |
85148a6
to
dd184f1
Compare
After the tests are complete this go routine verifies contents of console.txt and journal.txt through the use of CheckConsole. Ref: coreos#3788
I ran the code through the gofmt, yet it still fails the linter check. Can I get any pointers on this, please?
🤔 |
the CI runs gofmt and golangci-lint, which are two different things : https://golangci-lint.run/ |
I installed the version of golangci-lint as per the pipeline. The output seems to have nothing to do with code I modified. Here's the result of golangci-lint:
All golangci-lint errors I get for the harness.go, testiso.go and qemu.go seem to be unrelated to my modifications. Is this common, or am I missing something? |
Maybe can try newer go version like 1.22, see coreos/repo-templates#248 and coreos/repo-templates#249 (as 1.21 is EOL) |
I tried it and it didn't help:
|
go func() { | ||
err := <-errchan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This really doesn't need to be a goroutine I don't think (see the patch I put in #3895 (comment), it's not a goroutine, just code at the end of the function).
Though maybe there is some reason why it needs to be a goroutine? Convince me :)
// Check for badness using CheckConsoleText | ||
addWarnOnly, addBadlines := CheckConsoleText(output) | ||
if !addWarnOnly { | ||
warnOnly = false | ||
} | ||
badlines = append(badlines, addBadlines...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the value CheckConsoleText()
is adding here?
return "", err | ||
} | ||
return string(data), nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function isn't needed.. just use os.Readfile()
like is done here:
console, err = os.ReadFile(arg) |
This PR aims to address the first step of a suggestion in the #3788 issue.
CheckConsoleForBadness reads output from a journal pipe and checks each line for "badness". It then calls CheckConsoleText to analyze lines of Console output.