def monitor_env(shutdown=False, refresh=300): config = make_config([("irs", "repo_stats_cache_refresh_timeout", str(refresh))]) with MonkeyPatchScope([ (monitor, "sdCache", FakeStorageDomainCache()), (monitor, 'config', config), ]): event = FakeEvent() checker = FakeCheckService() thread = monitor.MonitorThread('uuid', 'host_id', MONITOR_INTERVAL, event, checker) try: yield MonitorEnv(thread, event, checker) finally: thread.stop(shutdown=shutdown) try: thread.join() except RuntimeError as e: log.error("Error joining thread: %s", e)
def test_initial_status(self): thread = monitor.MonitorThread('uuid', 'host_id', 0.2, None, None) status = thread.getStatus() self.assertFalse(status.actual) self.assertTrue(status.valid)