[fix] util stop_backend() should always try odemis-stop if nice request fails#3348
Conversation
…st fails If the backend does stop in time, it would call odemis-stop... however if the backend didn't even accept the request to stop, it would bail out immediately. => also call odemis-stop in such case. That should help for some automatic run of test cases
📝 WalkthroughWalkthroughThe 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Updates the test utility stop_backend() to be more robust by attempting a force-stop (odemis-stop) even when the initial “polite” stop request fails, improving reliability for automated test runs.
Changes:
- Change
stop_backend()flow to only wait for shutdown when the initialodemisd --killsucceeds. - When the
odemisd --killcommand fails, proceed to the fallback path (instead of raising immediately).
| else: | ||
| logging.warning("Backend still stopping after 15 s") | ||
| status = driver.BACKEND_DEAD | ||
| logging.warning("Failed stopping backend with '%s' (returned %d)", cmd, ret) |
There was a problem hiding this comment.
On non-zero return from the odemisd --kill command, this sets status = driver.BACKEND_DEAD, which forces the later sudo odemis-stop path even when there is actually no backend running (e.g. odemisd --kill exits non-zero with "No running back-end to kill"). Consider setting status = driver.get_backend_status() (or at least checking for BACKEND_STOPPED) so sudo odemis-stop is only attempted when the backend is still running/unresponsive.
| else: | ||
| logging.warning("Backend still stopping after 15 s") | ||
| status = driver.BACKEND_DEAD | ||
| logging.warning("Failed stopping backend with '%s' (returned %d)", cmd, ret) |
There was a problem hiding this comment.
The new behavior for the ret != 0 branch (falling back to sudo odemis-stop when the polite stop request fails) isn’t covered by a test. Adding a unit test that mocks subprocess.call to return non-zero and asserts the correct fallback behavior (and that it avoids calling sudo when get_backend_status() is already BACKEND_STOPPED) would help prevent regressions.
If the backend does stop in time, it would call odemis-stop... however
if the backend didn't even accept the request to stop, it would bail out
immediately.
=> also call odemis-stop in such case. That should help for some
automatic run of test cases