Skip to content

Improve test, get rid of sleep#2492

Merged
casperklein merged 2 commits intodocker-mailserver:masterfrom
casperklein:improve-test
Mar 20, 2022
Merged

Improve test, get rid of sleep#2492
casperklein merged 2 commits intodocker-mailserver:masterfrom
casperklein:improve-test

Conversation

@casperklein
Copy link
Copy Markdown
Member

@casperklein casperklein commented Mar 19, 2022

Description

This PR speeds up the test, by getting rid of sleep 15.

Before: The test waits 15 seconds and then checks for the string Manual certificates have changed in the changedetector log file.

After: The changedetector log file is constantly monitored until the string is found. If the string is not found within 15 seconds, the test fails.

The test time is reduced to ~6 seconds.

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 added area/tests kind/improvement Improve an existing feature, configuration file or the documentation labels Mar 19, 2022
@casperklein casperklein added this to the v11.0.0 milestone Mar 19, 2022
@casperklein casperklein self-assigned this Mar 19, 2022
@casperklein casperklein marked this pull request as ready for review March 19, 2022 01:47
@casperklein casperklein requested a review from a team March 19, 2022 01:47
Comment thread test/mail_ssl_manual.bats
run docker exec mail_manual_ssl /bin/bash -c "supervisorctl tail -3000 changedetector"
assert_output --partial 'Change detected'
assert_output --partial 'Manual certificates have changed'
run timeout 15 docker exec mail_manual_ssl bash -c "tail -F /var/log/supervisor/changedetector.log | sed '/Manual certificates have changed/ q'"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this a way to get the full log? I think I had difficulty with tests I wrote that could properly retrieve that, so I relied on the supervisor tail command instead which is problematic..


Just to confirm I understand the command, it will tail the log file, piping the output to sed until the log is updated with the line sed is looking for, then sed quits with success, or the timeout results in failure?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is this a way to get the full log?

In this case, yes. The log file does not exist when the test starts. That's why I used -F. It will start "tailing" as soon as the file exists.
If you go with the log files directly instead of supervisorctl tail, then you have the whole log available. I'll take a look at the other tests, that also uses supervisorctl tail and see, if those can also be improved. I wanted to discuss/merge this first, to see if that's a good way to go.

Just to confirm ...

Correct.

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.

LGTM 👍🏼

@casperklein casperklein merged commit d8d4b6a into docker-mailserver:master Mar 20, 2022
@casperklein casperklein deleted the improve-test branch March 20, 2022 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tests kind/improvement Improve an existing feature, configuration file or the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants