o/i/apparmorprompting: fix potential races when logging in tests - #17023
Conversation
Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
| c.Errorf("manager should still be ready") | ||
| } | ||
|
|
||
| time.Sleep(50 * time.Millisecond) |
There was a problem hiding this comment.
lol what was this doing here
There was a problem hiding this comment.
Basically what it said on the tin, waiting to give a chance for the message to be logged (though it shouldn't be). There's some annoyingness with the synchronization with mocked listener here, we don't have a synchronization point other than the run loop in o/i/a/prompting.go, so triggering the listener readiness isn't sufficient to know that the run loop has picked up the event and handled it.
But the nice thing is, mgr.Stop() is a synchronization point, since it kills the tomb and waits for it. And <-m.tomb.Dying() is in the run loop select, so if the manager stops, we know that the prior event is done being handled.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #17023 +/- ##
==========================================
+ Coverage 79.06% 79.07% +0.01%
==========================================
Files 1374 1376 +2
Lines 191076 191130 +54
Branches 2465 2465
==========================================
+ Hits 151065 151127 +62
+ Misses 30918 30899 -19
- Partials 9093 9104 +11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Tue May 5 17:46:36 UTC 2026 Spread tests skipped |
Small fixes to address potential race conditions around logging causing sporadic test failures.