def testForceRebootAfterGracePeriod(self, reboot_host, _, __): self.args.max_host_uptime = 60 self.assertTrue( main_helpers.reboot_gracefully(self.args, [mock.Mock()])) reboot_host.assert_called()
def testNoRebootBeforeMaxUptime(self, reboot_host, _, __): self.args.max_host_uptime = 60 self.assertFalse( main_helpers.reboot_gracefully(self.args, [mock.Mock()])) reboot_host.assert_not_called()
def testNoRebootWithContainers(self, reboot_host, _, __): self.args.max_host_uptime = 60 self.assertTrue( main_helpers.reboot_gracefully(self.args, [mock.Mock()])) reboot_host.assert_not_called()
def testRebootOnMaxHostUptime(self, reboot_host, _, __): self.args.max_host_uptime = 60 self.assertTrue(main_helpers.reboot_gracefully(self.args, [])) reboot_host.assert_called()
def testGracePeriodLargerThanCronFreq(self, reboot_host, _get_host_uptime): self.args.reboot_schedule = crontab.CronTab('0 * * * *') # every hour self.args.reboot_grace_period = 120 # 2 hours self.assertTrue( main_helpers.reboot_gracefully(self.args, [mock.Mock()])) reboot_host.assert_called()
def testNoRebootOnSchedule(self, reboot_host, _get_host_uptime): self.args.reboot_schedule = mock.Mock(spec=crontab.CronTab) self.args.reboot_schedule.next.return_value = 7200 # 2 hours self.assertFalse(main_helpers.reboot_gracefully(self.args, [])) reboot_host.assert_not_called()
def testRebootOnSchedule(self, reboot_host, _get_host_uptime): self.args.reboot_schedule = mock.Mock(spec=crontab.CronTab) self.args.reboot_schedule.next.return_value = 3000 # 50 minutes self.assertTrue(main_helpers.reboot_gracefully(self.args, [])) reboot_host.assert_called()