Example #1
0
 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()
Example #2
0
 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()
Example #3
0
 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()
Example #4
0
 def testRebootOnMaxHostUptime(self, reboot_host, _, __):
     self.args.max_host_uptime = 60
     self.assertTrue(main_helpers.reboot_gracefully(self.args, []))
     reboot_host.assert_called()
Example #5
0
 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()
Example #6
0
 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()
Example #7
0
 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()