-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LNDENG-636 (Shutdown/Reboot to DBus) #195
Conversation
Add dbus dependency to snapcraft.yaml
Updated changer to also use dbus
as it triggers actual reboot
(LNDENG-740)
Unit tests added for Shutdown/Restart logic. These don't test the dbus calls directly but ensure we are calling the necessary methods, or at least queuing them for the bus. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny inline comment.
Don't worry about the coverage failure. Codecov is being dumb and isn't comparing to the correct previous commit. If you push another commit it should be fine.
Removed unnecessary teardown method
Actually, looking at the coverage report was helpful. I assumed codecov was bad because it was using the wrong base commit, but there is also a real coverage issue. Because you're patching from unittest.mock import Mock, patch
...
def setUp(self):
super().setUp()
... # broker_service-related stuff
self.dbus_mock = patch("landscape.client.manager.shutdownmanager.dbus").start()
self.addCleanup(patch.stopall)
def test_reboot(self):
bus_object = Mock()
self.dbus_mock.SystemBus.return_value = bus_object
... # actually run stuff, resulting in deferred
def check(_):
bus_object.get_object.assert_called_once()
bus_object.Reboot.assert_called_once() # or assert specific args, if you want to be safe
return deferred Similar for |
assert calls on dbus object added clock advance for shutdown delay
Thanks Mitch, tests have been updated to mock at the lower layer as recommended. Seems much neater to me as well. For the shutdown test I had to add a clock to ensure the delayed call got triggered. That needed a small tweak to the actual shutdown code but nothing too disconcerting. Hopefully covcheck will pass now. |
Lint errors
Annoying frustrating Lints
Apologies. Forgot to mention in my prev comment that the deferred.addCallback(check)
return deferred |
Add callback to the shutdown tests
Tweaks to shutdownmanager to use deferLater.
Refactored reboot test in package/changer.py
Tests seem to be sensible and full coverage now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, good work!
Changed shutdown manager to use dbus calls instead of direct executables.
Changed reboot logic in package changer to also use dbus.
Removed unit tests that use old shutdown logic.