-
-
Notifications
You must be signed in to change notification settings - Fork 479
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
feat: fail-fast of wait.LogStrategy #1304
feat: fail-fast of wait.LogStrategy #1304
Conversation
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Hi @frozenbonito thanks for opening the issue and taking the time to elaborate a PR 💪 I think it makes sense to check for logs length to verify if the log changed after each poll of the logs. I'm labelling the PR as |
Taking a deeper look at the current code, I see that we are extracting the state of the container, but we are evaluating if there is an error too late 🤔. I've double checked all the usages of the We could probably fix that logic, keeping the bug nature, like this: checkErr := checkTarget(ctx, target)
+ if checkErr != nil {
+ return checkErr
+ }
reader, err := target.Logs(ctx)
if err != nil {
time.Sleep(ws.PollInterval)
continue
}
b, err := io.ReadAll(reader)
if err != nil {
time.Sleep(ws.PollInterval)
continue
}
logs := string(b)
- if logs == "" && checkErr != nil {
- return checkErr
+ if logs == "" {
+ return fmt.Errorf("no logs found")
} else if strings.Count(logs, ws.Log) >= ws.Occurrence {
break LOOP
} else {
time.Sleep(ws.PollInterval)
continue
} Thoughts? |
@mdelapenya Thank you for comments. I think LogStrategy is special case. If we evaluate and return the error of testcontainers-go/docker_test.go Lines 1203 to 1228 in f5a4a54
|
Ah this makes even more sense now, sorry for not recalling that very same conversation 🤦
Then this changes makes sense. Let me fix the issue with the current state of the CI, caused by the recent changes in Go + Moby (see #1394), as any CI job will fail because of that (unless we pin the Go versions) |
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.
LGTM! Will merge this one right after fixing the errors with Go+Moby+Host header validation
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
What does this PR do?
This PR fixes the check that the container is not emitting new logs (please refer this comment).
logs
variable contains all logs after container start, so it can never be an empty string. Therefore, comparisons with empty strings are meaningless.Instead, it is verified that the length of the logs has not changed since the last check in this PR.
This fix broke
Test_GetLogsFromFailedContainer
, so I fixed it too.Why is it important?
When the container stop, LogStrategy should fail-fast, but it doesn't.
This PR will fix it.
Related issues