tests: net: conn_mgr_monitor: Improve test reliability under heavy load #79710
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
conn_mgr_tests were occasionally failing when executed under heavy load. The reason for this are short timeout values used when waiting for events - if executed under heavy load, the even might not be delivered on time.
An obvious solution would be to simply increase the timeout, however when testing it turned out the actual timeout value would need to be pretty high to ensure tests reliability. Therefore, to avoid unnecessary increase of the overall test execution time to protect against rare edge cases, rework the event waiting mechanism to use semaphore instead. The test cases will now specify the events they're waiting for, and the event handlers will feed the semaphore if all expected events have been delivered. This allows the increase the maximum timeout when waiting for events, w/o affecting too much the test execution time under normal conditions.