def test_paths_in_omd_and_opt_root(monkeypatch): omd_root = '/omd/sites/dingeling' with monkeypatch.context() as m: m.setitem(os.environ, 'OMD_ROOT', omd_root) test_paths = import_module("%s/cmk/utils/paths.py" % repo_path()) _check_paths(omd_root, test_paths)
def fixture_test_thread_1(locked_file): # HACK: We abuse modules as data containers, so we have to do this Kung Fu... t_store = import_module("cmk/utils/store.py") t = LockTestThread(t_store, locked_file) t.start() yield t t.store.release_all_locks() t.terminate()
def test_locking(tmp_path, path_type): # HACK: We abuse modules as data containers, so we have to do this Kung Fu... store1 = store store2 = import_module("cmk/utils/store.py") assert store1 != store2 locked_file_path = tmp_path.joinpath("locked_file") with locked_file_path.open(mode="w", encoding="utf-8") as locked_file: locked_file.write(u"") path = "%s" % locked_file_path t1 = LockTestThread(store1, path) t1.start() t2 = LockTestThread(store2, path) t2.start() # Take lock with store1 t1.do = "lock" while range(20): if store1.have_lock(path): break time.sleep(0.01) assert store1.have_lock(path) is True # Now try to get lock with store2 t2.do = "lock" time.sleep(0.2) assert store1.have_lock(path) is True assert store2.have_lock(path) is False # And now unlock store1 and check whether store2 has the lock now t1.do = "unlock" while range(20): if not store1.have_lock(path): break time.sleep(0.01) assert store1.have_lock(path) is False time.sleep(0.2) assert store2.have_lock(path) is True # Not 100% safe, but protects agains left over ressources in the good case at least store1.release_all_locks() store2.release_all_locks() t1.terminate() t1.join() t2.terminate() t2.join()
def mk_logwatch(): return import_module("agents/plugins/mk_logwatch")
def mk_filestats(): return import_module("agents/plugins/mk_filestats.py")
def check_uniserv(): return import_module("active_checks/check_uniserv")
def mk_jolokia(): return import_module("agents/plugins/mk_jolokia.py")
def mk_docker(): return import_module("agents/plugins/mk_docker.py")
def check_mail(): return import_module("active_checks/check_mail")
def check_mail_loop(): return import_module("active_checks/check_mail_loop")
def check_traceroute(): return import_module("active_checks/check_traceroute")
def apache_status(): return import_module("agents/plugins/apache_status")
def check_form_submit(): return import_module("active_checks/check_form_submit")
def mk_mongodb(): return import_module("agents/plugins/mk_mongodb")