Improve test, get rid of sleep#2492
Conversation
| 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'" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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 changedin 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
Checklist:
docs/)