-
Notifications
You must be signed in to change notification settings - Fork 58
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
e2e: add logfile for e2e tests #1775
Conversation
Good to link the issue, but we should start a PR with a commit message describing the change. We can describe what was done and what will be done later. This helps people to review the change. |
13a1f0c
to
f242964
Compare
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.
Looks good! just minor comments about comments.
5fea441
to
895283d
Compare
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.
Looks good, minor comment about .gitignore
This is clear when you look at the commits, it will help to explain int the commit/pr message why we revert the previous logging hack. |
895283d
to
c3e3faf
Compare
c3e3faf
to
fdd8d4c
Compare
This commit introduces a dedicated log file for e2e tests: * Creates a log file (ramen-e2e.log) in the current directory by default. * Log DEBUG level messages to the file and INFO level messages to the console. * Remove caller (file:lineno) from console logs for cleaner output. * Added /e2e/ramen-e2e and /e2e/ramen-e2e.log to gitignore. Signed-off-by: Parikshith <pbyregow@redhat.com>
This reverts commit 2cd063a. which previously redirected e2e test logs to ramen-e2e.log using tee. This change is no longer needed because the new logger implementation now writes to ramen-e2e.log by default. Signed-off-by: Parikshith <pbyregow@redhat.com>
fdd8d4c
to
9990c5f
Compare
if err != nil { | ||
panic(err) | ||
} | ||
|
||
log := logger.Sugar() | ||
// TODO: Sync the log on exit |
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.
It seems that the best way to handle the conflict between os.Exit() and defer is to call it only once in main() or in the case of tests, in TestMain(). This also means we cannot call any function that calls os.Exit() like log.Fatal().
We can do this like this:
func TestMain(m *testing.M) {
os.Exit(run(m))
}
func run(m *testing.M) int {
log := ...
defer func() {
_ = log.Sync()
}()
...
if err != nil {
log.Errorf("error message... : %s", err)
return 1
}
return m.Run()
}
With this we ensure that test failure or setup failure will return non-zero exit code, and defer function will run, and the code is very simple.
But lets no dalay this good change, we can improve this later.
Fixes: #1722