remote_access.py: avoid races and uncertainty in remote reboot
If sshd fails while requesting a reboot, we don't know if
the reboot succeeded (or if it even got started). The
current strategy is flawed, because we also don't know if
the "reboot marker" file was created or not. Instead use
the same strategy as the remote reboot in autotest, that
is, compare the system-provided reboot ID before and after
the reboot attempt.
BUG=chromium:667541
TEST=none
Change-Id: If770f2bf29c210a0a8396d1d4d5f7dd8610a54c5
Reviewed-on: https://chromium-review.googlesource.com/413632
Commit-Ready: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/scripts/deploy_chrome_unittest.py b/scripts/deploy_chrome_unittest.py
index 6579090..ac5cf3d 100644
--- a/scripts/deploy_chrome_unittest.py
+++ b/scripts/deploy_chrome_unittest.py
@@ -161,7 +161,9 @@
self.deploy_mock = self.StartPatcher(DeployChromeMock())
self.deploy = self._GetDeployChrome(
list(_REGULAR_TO) + ['--gs-path', _GS_PATH, '--force'])
-
+ self.remote_reboot_mock = \
+ self.PatchObject(remote_access.RemoteAccess, 'RemoteReboot',
+ return_value=True)
class TestDisableRootfsVerification(DeployTest):
"""Testing disabling of rootfs verification and RO mode."""
@@ -174,8 +176,13 @@
def testDisableRootfsVerificationFailure(self):
"""Test failure to disable rootfs verification."""
+ #pylint: disable=unused-argument
+ def RaiseRunCommandError(timeout_sec=None):
+ raise cros_build_lib.RunCommandError('Mock RunCommandError', 0)
+ self.remote_reboot_mock.side_effect = RaiseRunCommandError
self.assertRaises(cros_build_lib.RunCommandError,
self.deploy._DisableRootfsVerification)
+ self.remote_reboot_mock.side_effect = None
self.assertFalse(self.deploy._target_dir_is_still_readonly.is_set())