Skip to content

tests: Wait at least 30 seconds before checking the health state of the container#2777

Merged
casperklein merged 4 commits intodocker-mailserver:masterfrom
casperklein:fix-healthcheck-race-condition
Sep 19, 2022
Merged

tests: Wait at least 30 seconds before checking the health state of the container#2777
casperklein merged 4 commits intodocker-mailserver:masterfrom
casperklein:fix-healthcheck-race-condition

Conversation

@casperklein
Copy link
Copy Markdown
Member

@casperklein casperklein commented Sep 18, 2022

Description

This PR fixes failed health-checks like this, when the CI is faster than 30 seconds when running the health check (container isn't healthy yet at this point --> first health check is run after 30 seconds):

not ok 219 checking container healthcheck in 113ms
# (from function `assert_output' in file test/test_helper/bats-assert/src/assert_output.bash, line 194,
#  in test file test/tests.bats, line 114)
#   `assert_output "healthy"' failed
#
# -- output differs --
# expected : healthy
# actual   : starting

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (non-breaking change that does improve existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (README.md or the documentation under docs/)
  • If necessary I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@casperklein casperklein requested a review from a team September 18, 2022 12:52
@casperklein casperklein marked this pull request as ready for review September 18, 2022 12:56
Copy link
Copy Markdown
Member

@polarathene polarathene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative might be to shift the test to the end of the file (but should keep the note about 30 sec requirement), or moving to a separate test file.

@casperklein
Copy link
Copy Markdown
Member Author

or moving to a separate test file.

I thought about this also, but that would at 30 seconds to the overall test run time. The solution I provided added max 1-2 seconds in my tests and ensures, that the test succeed.

I prefer this solution, as it is bullet proof. Moving the test more to the bottom could help, but might fail in the future again.

Copy link
Copy Markdown
Member

@georglauterbach georglauterbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@casperklein casperklein merged commit b906d1b into docker-mailserver:master Sep 19, 2022
@casperklein casperklein deleted the fix-healthcheck-race-condition branch September 19, 2022 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants