def fake_version_and_paths(): if is_running_as_site_user(): return import _pytest.monkeypatch # type: ignore monkeypatch = _pytest.monkeypatch.MonkeyPatch() tmp_dir = tempfile.mkdtemp(prefix="pytest_cmk_") import cmk # TODO: handle CME case #if is_managed_repo(): # monkeypatch.setattr(cmk, "omd_version", lambda: "%s.cee" % cmk.__version__) #elif is_enterprise_repo(): if is_enterprise_repo(): monkeypatch.setattr(cmk, "omd_version", lambda: "%s.cee" % cmk.__version__) else: monkeypatch.setattr(cmk, "omd_version", lambda: "%s.cre" % cmk.__version__) monkeypatch.setattr("cmk.utils.paths.agents_dir", "%s/agents" % cmk_path()) monkeypatch.setattr("cmk.utils.paths.checks_dir", "%s/checks" % cmk_path()) monkeypatch.setattr("cmk.utils.paths.notifications_dir", Path(cmk_path()) / "notifications") monkeypatch.setattr("cmk.utils.paths.inventory_dir", "%s/inventory" % cmk_path()) monkeypatch.setattr("cmk.utils.paths.check_manpages_dir", "%s/checkman" % cmk_path()) monkeypatch.setattr("cmk.utils.paths.web_dir", "%s/web" % cmk_path()) monkeypatch.setattr("cmk.utils.paths.omd_root", tmp_dir) monkeypatch.setattr("cmk.utils.paths.tmp_dir", os.path.join(tmp_dir, "tmp/check_mk")) monkeypatch.setattr("cmk.utils.paths.tcp_cache_dir", os.path.join(tmp_dir, "tmp/check_mk/cache")) monkeypatch.setattr( "cmk.utils.paths.data_source_cache_dir", os.path.join(tmp_dir, "tmp/check_mk/data_source_cache")) monkeypatch.setattr("cmk.utils.paths.var_dir", os.path.join(tmp_dir, "var/check_mk")) monkeypatch.setattr( "cmk.utils.paths.precompiled_checks_dir", os.path.join(tmp_dir, "var/check_mk/precompiled_checks")) monkeypatch.setattr("cmk.utils.paths.crash_dir", Path(cmk.utils.paths.var_dir) / "crashes") monkeypatch.setattr("cmk.utils.paths.include_cache_dir", os.path.join(tmp_dir, "tmp/check_mk/check_includes")) monkeypatch.setattr("cmk.utils.paths.check_mk_config_dir", os.path.join(tmp_dir, "etc/check_mk/conf.d")) monkeypatch.setattr("cmk.utils.paths.main_config_file", os.path.join(tmp_dir, "etc/check_mk/main.mk")) monkeypatch.setattr("cmk.utils.paths.default_config_dir", os.path.join(tmp_dir, "etc/check_mk")) monkeypatch.setattr("cmk.utils.paths.piggyback_dir", Path(tmp_dir) / "var/check_mk/piggyback") monkeypatch.setattr("cmk.utils.paths.piggyback_source_dir", Path(tmp_dir) / "var/check_mk/piggyback_sources") monkeypatch.setattr("cmk.utils.paths.htpasswd_file", os.path.join(tmp_dir, "etc/htpasswd"))
def editions(): yield ("cre", "CRESnapshotManager") if is_enterprise_repo(): yield ("cee", "CRESnapshotManager") if is_managed_repo(): yield ("cme", "CMESnapshotManager")
def _get_files_to_check(pylint_test_dir): p = subprocess.Popen( ["%s/scripts/find-python-files" % repo_path(), str(sys.version_info[0])], stdout=subprocess.PIPE, shell=False, close_fds=True, ) stdout = p.communicate()[0] files = [] for fname in stdout.splitlines(): # Thin out these excludes some day... rel_path = fname[len(repo_path()) + 1:] # Can currently not be checked alone. Are compiled together below if rel_path.startswith("checks/") or \ rel_path.startswith("inventory/") or \ rel_path.startswith("agents/bakery/") or \ rel_path.startswith("enterprise/agents/bakery/"): continue # TODO: We should also test them... if rel_path == "werk" \ or rel_path.startswith("tests/") \ or rel_path.startswith("scripts/") \ or rel_path.startswith("agents/wnx/integration/"): continue # TODO: disable random, not that important stuff if rel_path.startswith("agents/windows/it/") \ or rel_path.startswith("agents/windows/msibuild/") \ or rel_path.startswith("doc/") \ or rel_path.startswith("livestatus/api/python/example") \ or rel_path.startswith("livestatus/api/python/make_"): continue files.append(fname) # Add the compiled files for things that are no modules yet open(pylint_test_dir + "/__init__.py", "w") _compile_check_and_inventory_plugins(pylint_test_dir) if is_enterprise_repo(): _compile_bakery_plugins(pylint_test_dir) # Not checking compiled check, inventory, bakery plugins with Python 3 if sys.version_info[0] == 3: files += [ pylint_test_dir, ] return files
def register(linter): verify_pylint_version() # Disable some CEE/CME specific things when linting CRE repos if not is_enterprise_repo(): # Is used to disable import-error. Would be nice if no-name-in-module could be # disabled using this, but this does not seem to be possible :( linter.global_set_option( "ignored-modules", "cmk.base.cee,cmk.gui.cee,cmk.gui.cme,cmk.gui.cme.managed") # This disables no-member errors linter.global_set_option( "generated-members", r"(cmk\.base\.cee|cmk\.gui\.cee|cmk\.gui\.cme)(\..*)?") linter.register_reporter(CMKColorizedTextReporter) linter.register_reporter(CMKParseableTextReporter)
def scenario_fixture(monkeypatch): test_hosts = ["ds-test-host1", "ds-test-host2", "ds-test-node1", "ds-test-node2"] ts = Scenario() if is_enterprise_repo(): ts.set_option("monitoring_core", "cmc") else: ts.set_option("monitoring_core", "nagios") for h in test_hosts: ts.add_host(h) ts.set_option("ipaddresses", dict((h, "127.0.0.1") for h in test_hosts)) ts.add_cluster("ds-test-cluster1", nodes=["ds-test-node1", "ds-test-node2"]) ts.fake_standard_linux_agent_output(*test_hosts) return ts.apply(monkeypatch)
def fake_version_and_paths(): if is_running_as_site_user(): return import _pytest.monkeypatch # type: ignore # pylint: disable=import-outside-toplevel monkeypatch = _pytest.monkeypatch.MonkeyPatch() tmp_dir = tempfile.mkdtemp(prefix="pytest_cmk_") import cmk.utils.version as cmk_version # pylint: disable=import-outside-toplevel import cmk.utils.paths # pylint: disable=import-outside-toplevel # TODO: handle CME case #if is_managed_repo(): # monkeypatch.setattr(cmk_version, "omd_version", lambda: "%s.cee" % cmk_version.__version__) #elif is_enterprise_repo(): if is_enterprise_repo(): monkeypatch.setattr(cmk_version, "omd_version", lambda: "%s.cee" % cmk_version.__version__) else: monkeypatch.setattr(cmk_version, "omd_version", lambda: "%s.cre" % cmk_version.__version__) monkeypatch.setattr("cmk.utils.paths.agents_dir", "%s/agents" % cmk_path()) monkeypatch.setattr("cmk.utils.paths.checks_dir", "%s/checks" % cmk_path()) monkeypatch.setattr("cmk.utils.paths.notifications_dir", Path(cmk_path()) / "notifications") monkeypatch.setattr("cmk.utils.paths.inventory_dir", "%s/inventory" % cmk_path()) monkeypatch.setattr("cmk.utils.paths.inventory_output_dir", os.path.join(tmp_dir, "var/check_mk/inventory")) monkeypatch.setattr("cmk.utils.paths.inventory_archive_dir", os.path.join(tmp_dir, "var/check_mk/inventory_archive")) monkeypatch.setattr("cmk.utils.paths.check_manpages_dir", "%s/checkman" % cmk_path()) monkeypatch.setattr("cmk.utils.paths.web_dir", "%s/web" % cmk_path()) monkeypatch.setattr("cmk.utils.paths.omd_root", tmp_dir) monkeypatch.setattr("cmk.utils.paths.tmp_dir", os.path.join(tmp_dir, "tmp/check_mk")) monkeypatch.setattr("cmk.utils.paths.counters_dir", os.path.join(tmp_dir, "tmp/check_mk/counters")) monkeypatch.setattr("cmk.utils.paths.tcp_cache_dir", os.path.join(tmp_dir, "tmp/check_mk/cache")) monkeypatch.setattr("cmk.utils.paths.data_source_cache_dir", os.path.join(tmp_dir, "tmp/check_mk/data_source_cache")) monkeypatch.setattr("cmk.utils.paths.var_dir", os.path.join(tmp_dir, "var/check_mk")) monkeypatch.setattr("cmk.utils.paths.autochecks_dir", os.path.join(tmp_dir, "var/check_mk/autochecks")) monkeypatch.setattr("cmk.utils.paths.precompiled_checks_dir", os.path.join(tmp_dir, "var/check_mk/precompiled_checks")) monkeypatch.setattr("cmk.utils.paths.crash_dir", Path(cmk.utils.paths.var_dir) / "crashes") monkeypatch.setattr("cmk.utils.paths.include_cache_dir", os.path.join(tmp_dir, "tmp/check_mk/check_includes")) monkeypatch.setattr("cmk.utils.paths.check_mk_config_dir", os.path.join(tmp_dir, "etc/check_mk/conf.d")) monkeypatch.setattr("cmk.utils.paths.main_config_file", os.path.join(tmp_dir, "etc/check_mk/main.mk")) monkeypatch.setattr("cmk.utils.paths.default_config_dir", os.path.join(tmp_dir, "etc/check_mk")) monkeypatch.setattr("cmk.utils.paths.piggyback_dir", Path(tmp_dir) / "var/check_mk/piggyback") monkeypatch.setattr("cmk.utils.paths.piggyback_source_dir", Path(tmp_dir) / "var/check_mk/piggyback_sources") monkeypatch.setattr("cmk.utils.paths.htpasswd_file", os.path.join(tmp_dir, "etc/htpasswd")) monkeypatch.setattr("cmk.utils.paths.local_share_dir", Path(tmp_dir, "local/share/check_mk")) monkeypatch.setattr("cmk.utils.paths.local_checks_dir", Path(tmp_dir, "local/share/check_mk/checks")) monkeypatch.setattr("cmk.utils.paths.local_notifications_dir", Path(tmp_dir, "local/share/check_mk/notifications")) monkeypatch.setattr("cmk.utils.paths.local_inventory_dir", Path(tmp_dir, "local/share/check_mk/inventory")) monkeypatch.setattr("cmk.utils.paths.local_check_manpages_dir", Path(tmp_dir, "local/share/check_mk/checkman")) monkeypatch.setattr("cmk.utils.paths.local_agents_dir", Path(tmp_dir, "local/share/check_mk/agents")) monkeypatch.setattr("cmk.utils.paths.local_web_dir", Path(tmp_dir, "local/share/check_mk/web")) monkeypatch.setattr("cmk.utils.paths.local_pnp_templates_dir", Path(tmp_dir, "local/share/check_mk/pnp-templates")) monkeypatch.setattr("cmk.utils.paths.local_doc_dir", Path(tmp_dir, "local/share/doc/check_mk")) monkeypatch.setattr("cmk.utils.paths.local_locale_dir", Path(tmp_dir, "local/share/check_mk/locale")) monkeypatch.setattr("cmk.utils.paths.local_bin_dir", Path(tmp_dir, "local/bin")) monkeypatch.setattr("cmk.utils.paths.local_lib_dir", Path(tmp_dir, "local/lib")) monkeypatch.setattr("cmk.utils.paths.local_mib_dir", Path(tmp_dir, "local/share/snmp/mibs"))
def test_generate_pre_17_site_snapshot(edition_short, monkeypatch, tmp_path, with_user_login): snapshot_data_collector_class = ("CMESnapshotDataCollector" if edition_short == "cme" else "CRESnapshotDataCollector") is_pre_17_site = True monkeypatch.setattr(cmk_version, "edition_short", lambda: edition_short) monkeypatch.setattr(activate_changes, "_is_pre_17_remote_site", lambda s: is_pre_17_site) activation_manager = _get_activation_manager(monkeypatch) snapshot_settings = _create_sync_snapshot(activation_manager, snapshot_data_collector_class, monkeypatch, tmp_path, is_pre_17_site) # And now check the resulting snapshot contents unpack_dir = tmp_path / "snapshot_unpack" if unpack_dir.exists(): shutil.rmtree(str(unpack_dir)) with tarfile.open(snapshot_settings.snapshot_path, "r") as t: t.extractall(str(unpack_dir)) expected_subtars = [ "auth.secret.tar", "auth.serials.tar", "check_mk.tar", "diskspace.tar", "htpasswd.tar", "mkeventd_mkp.tar", "mkeventd.tar", "multisite.tar", "sitespecific.tar", "usersettings.tar", ] if is_enterprise_repo(): expected_subtars += [ "dcd.tar", "mknotify.tar", ] if not cmk_version.is_raw_edition(): expected_subtars.append("liveproxyd.tar") if cmk_version.is_managed_edition(): expected_subtars += [ "customer_check_mk.tar", "customer_gui_design.tar", "customer_multisite.tar", "gui_logo.tar", "gui_logo_dark.tar", "gui_logo_facelift.tar", ] assert sorted(f.name for f in unpack_dir.iterdir()) == sorted(expected_subtars) expected_files = { 'mkeventd_mkp.tar': [], 'multisite.tar': ["global.mk", "users.mk"], 'usersettings.tar': [with_user_login], 'mkeventd.tar': [], 'check_mk.tar': ["hosts.mk", "contacts.mk"], 'htpasswd.tar': ["htpasswd"], 'liveproxyd.tar': [], 'sitespecific.tar': ['sitespecific.mk'], 'auth.secret.tar': [], 'dcd.tar': [], 'auth.serials.tar': ["auth.serials"], 'mknotify.tar': [], 'diskspace.tar': [], } # type: Dict[str, List[str]] if cmk_version.is_managed_edition(): expected_files.update({ "customer_check_mk.tar": ["customer.mk"], "customer_gui_design.tar": [], "customer_multisite.tar": ["customer.mk"], "gui_logo.tar": [], "gui_logo_dark.tar": [], "gui_logo_facelift.tar": [], # TODO: Shouldn't we clean up these subtle differences? "mkeventd.tar": ["rules.mk"], 'check_mk.tar': ["groups.mk", "contacts.mk"], 'multisite.tar': [ "bi.mk", "customers.mk", "global.mk", "groups.mk", "user_connections.mk", "users.mk", ], }) if not cmk_version.is_raw_edition(): expected_files['liveproxyd.tar'] = [] # And now check the subtar contents for subtar in unpack_dir.iterdir(): subtar_unpack_dir = unpack_dir / subtar.stem subtar_unpack_dir.mkdir(parents=True, exist_ok=True) with tarfile.open(str(subtar), "r") as s: s.extractall(str(subtar_unpack_dir)) files = sorted( str(f.relative_to(subtar_unpack_dir)) for f in subtar_unpack_dir.iterdir()) assert sorted(expected_files[subtar.name]) == files, \ "Subtar %s has wrong files" % subtar.name
def _get_expected_paths(user_id, is_pre_17_site): expected_paths = [ 'etc', 'var', 'etc/check_mk', 'etc/check_mk/conf.d', 'etc/check_mk/mkeventd.d', 'etc/check_mk/multisite.d', 'etc/check_mk/conf.d/wato', 'etc/check_mk/conf.d/wato/hosts.mk', 'etc/check_mk/conf.d/wato/contacts.mk', 'etc/check_mk/mkeventd.d/wato', 'etc/check_mk/multisite.d/wato', 'etc/check_mk/multisite.d/wato/global.mk', 'var/check_mk', 'var/check_mk/web', "etc/htpasswd", "etc/auth.serials", "etc/check_mk/multisite.d/wato/users.mk", six.ensure_str('var/check_mk/web/%s' % user_id), six.ensure_str('var/check_mk/web/%s/cached_profile.mk' % user_id), six.ensure_str('var/check_mk/web/%s/enforce_pw_change.mk' % user_id), six.ensure_str('var/check_mk/web/%s/last_pw_change.mk' % user_id), six.ensure_str('var/check_mk/web/%s/num_failed_logins.mk' % user_id), six.ensure_str('var/check_mk/web/%s/serial.mk' % user_id), ] # The new sync directories create all needed files on the central site now if not is_pre_17_site: expected_paths += [ 'etc/check_mk/apache.d', 'etc/check_mk/apache.d/wato', 'etc/check_mk/apache.d/wato/sitespecific.mk', 'etc/check_mk/conf.d/distributed_wato.mk', 'etc/check_mk/conf.d/wato/sitespecific.mk', 'etc/check_mk/mkeventd.d/wato/sitespecific.mk', 'etc/check_mk/multisite.d/wato/ca-certificates_sitespecific.mk', 'etc/check_mk/multisite.d/wato/sitespecific.mk', 'etc/check_mk/rrdcached.d', 'etc/check_mk/rrdcached.d/wato', 'etc/check_mk/rrdcached.d/wato/sitespecific.mk', 'etc/omd', 'etc/omd/sitespecific.mk', ] if is_enterprise_repo(): expected_paths += [ 'etc/check_mk/dcd.d/wato/sitespecific.mk', 'etc/check_mk/mknotifyd.d/wato/sitespecific.mk', ] if not cmk_version.is_raw_edition(): expected_paths += ['etc/check_mk/dcd.d/wato/distributed.mk'] # TODO: The second condition should not be needed. Seems to be a subtle difference between the # CME and CRE/CEE snapshot logic if not cmk_version.is_managed_edition(): expected_paths += [ 'etc/check_mk/mkeventd.d/mkp', 'etc/check_mk/mkeventd.d/mkp/rule_packs', ] # The paths are registered once the enterprise plugins are available, independent of the # cmk_version.edition_short() value. # TODO: The second condition should not be needed. Seems to be a subtle difference between the # CME and CRE/CEE snapshot logic if is_enterprise_repo() and (not is_pre_17_site or not cmk_version.is_managed_edition()): expected_paths += [ 'etc/check_mk/dcd.d', 'etc/check_mk/dcd.d/wato', 'etc/check_mk/mknotifyd.d', 'etc/check_mk/mknotifyd.d/wato', ] # TODO: Shouldn't we clean up these subtle differences? if cmk_version.is_managed_edition(): expected_paths += [ "etc/check_mk/conf.d/customer.mk", "etc/check_mk/conf.d/wato/groups.mk", "etc/check_mk/mkeventd.d/wato/rules.mk", "etc/check_mk/multisite.d/customer.mk", "etc/check_mk/multisite.d/wato/bi.mk", "etc/check_mk/multisite.d/wato/customers.mk", "etc/check_mk/multisite.d/wato/groups.mk", "etc/check_mk/multisite.d/wato/user_connections.mk", ] expected_paths.remove("etc/check_mk/conf.d/wato/hosts.mk") # TODO: The second condition should not be needed. Seems to be a subtle difference between the # CME and CRE/CEE snapshot logic if not cmk_version.is_raw_edition() and not cmk_version.is_managed_edition( ): expected_paths += [ 'etc/check_mk/liveproxyd.d', 'etc/check_mk/liveproxyd.d/wato', ] return expected_paths
def test_apply_sync_snapshot(edition_short, snapshot_manager_class, monkeypatch, tmp_path, with_user): user_id = with_user[0] monkeypatch.setattr(cmk_version, "edition_short", lambda: edition_short) environ = dict(create_environ(), REQUEST_URI='') with AppContext(DummyApplication(environ, None)), \ RequestContext(htmllib.html(Request(environ))): login.login(user_id) _create_test_sync_config(monkeypatch) snapshot_settings = _create_sync_snapshot(snapshot_manager_class, monkeypatch, tmp_path) # Change unpack target directory from "unit test site" paths to a test specific path unpack_dir = tmp_path / "snapshot_unpack" components = [ activate_changes._replace_omd_root(str(unpack_dir), p) for p in activate_changes.get_replication_paths() ] with open(snapshot_settings.snapshot_path, "rb") as f: activate_changes.apply_sync_snapshot("unit_remote_1", f.read(), components) expected_paths = [ 'etc', 'var', 'etc/check_mk', 'etc/check_mk/conf.d', 'etc/check_mk/mkeventd.d', 'etc/check_mk/multisite.d', 'etc/check_mk/conf.d/wato', 'etc/check_mk/conf.d/wato/hosts.mk', 'etc/check_mk/conf.d/wato/contacts.mk', 'etc/check_mk/mkeventd.d/mkp', 'etc/check_mk/mkeventd.d/wato', 'etc/check_mk/mkeventd.d/mkp/rule_packs', 'etc/check_mk/multisite.d/wato', 'etc/check_mk/multisite.d/wato/global.mk', 'var/check_mk', 'var/check_mk/web', "etc/htpasswd", "etc/auth.serials", "etc/check_mk/multisite.d/wato/users.mk", six.ensure_str('var/check_mk/web/%s' % user_id), six.ensure_str('var/check_mk/web/%s/cached_profile.mk' % user_id), six.ensure_str('var/check_mk/web/%s/enforce_pw_change.mk' % user_id), six.ensure_str('var/check_mk/web/%s/last_pw_change.mk' % user_id), six.ensure_str('var/check_mk/web/%s/num_failed_logins.mk' % user_id), six.ensure_str('var/check_mk/web/%s/serial.mk' % user_id), ] # The paths are registered once the enterprise plugins are available, independent of the # cmk_version.edition_short() value. if is_enterprise_repo(): expected_paths += [ 'etc/check_mk/dcd.d', 'etc/check_mk/mknotifyd.d', 'etc/check_mk/mknotifyd.d/wato', 'etc/check_mk/dcd.d/wato', ] # TODO: Shouldn't we clean up these subtle differences? if cmk_version.is_managed_edition(): expected_paths += [ "etc/check_mk/conf.d/wato/groups.mk", "etc/check_mk/mkeventd.d/wato/rules.mk", "etc/check_mk/multisite.d/wato/bi.mk", "etc/check_mk/multisite.d/wato/customers.mk", "etc/check_mk/multisite.d/wato/groups.mk", "etc/check_mk/multisite.d/wato/user_connections.mk", #"etc/check_mk/conf.d/wato/sitespecific.mk", #"etc/check_mk/dcd.d/wato/distributed.mk", #"etc/check_mk/dcd.d/wato/sitespecific.mk", #"etc/check_mk/mkeventd.d/wato/sitespecific.mk", #"etc/check_mk/mknotifyd.d/wato/sitespecific.mk", #"etc/check_mk/multisite.d/wato/sitespecific.mk", ] expected_paths.remove("etc/check_mk/conf.d/wato/hosts.mk") if not cmk_version.is_raw_edition(): expected_paths += [ 'etc/check_mk/liveproxyd.d', 'etc/check_mk/liveproxyd.d/wato', #'etc/check_mk/multisite.d/wato/ca-certificates_sitespecific.mk', ] paths = [str(p.relative_to(unpack_dir)) for p in unpack_dir.glob("**/*")] assert sorted(paths) == sorted(expected_paths)
def test_generate_snapshot(edition_short, snapshot_manager_class, monkeypatch, tmp_path, with_user): user_id = with_user[0] monkeypatch.setattr(cmk_version, "edition_short", lambda: edition_short) environ = dict(create_environ(), REQUEST_URI='') with AppContext(DummyApplication(environ, None)), \ RequestContext(htmllib.html(Request(environ))): login.login(user_id) _create_test_sync_config(monkeypatch) snapshot_settings = _create_sync_snapshot(snapshot_manager_class, monkeypatch, tmp_path) # And now check the resulting snapshot contents unpack_dir = tmp_path / "snapshot_unpack" with tarfile.open(snapshot_settings.snapshot_path, "r") as t: t.extractall(str(unpack_dir)) expected_subtars = [ "auth.secret.tar", "auth.serials.tar", "check_mk.tar", "diskspace.tar", "htpasswd.tar", "mkeventd_mkp.tar", "mkeventd.tar", "multisite.tar", "sitespecific.tar", "usersettings.tar", ] if is_enterprise_repo(): expected_subtars += [ "dcd.tar", "mknotify.tar", ] if not cmk_version.is_raw_edition(): expected_subtars.append("liveproxyd.tar") assert sorted(f.name for f in unpack_dir.iterdir()) == sorted(expected_subtars) expected_files = { 'mkeventd_mkp.tar': [], 'multisite.tar': ["global.mk", "users.mk"], 'usersettings.tar': [user_id], 'mkeventd.tar': [], 'check_mk.tar': ["hosts.mk", "contacts.mk"], 'htpasswd.tar': ["htpasswd"], 'liveproxyd.tar': [], 'sitespecific.tar': ['sitespecific.mk'], 'auth.secret.tar': [], 'dcd.tar': [], 'auth.serials.tar': ["auth.serials"], 'mknotify.tar': [], 'diskspace.tar': [], } # TODO: Shouldn't we clean up these subtle differences? if cmk_version.is_managed_edition(): expected_files.update({ "mkeventd.tar": ["rules.mk"], 'check_mk.tar': ["groups.mk", "contacts.mk"], 'multisite.tar': [ "bi.mk", "customers.mk", "global.mk", "groups.mk", "user_connections.mk", "users.mk", ], }) if not cmk_version.is_raw_edition(): expected_files['liveproxyd.tar'] = [] # And now check the subtar contents for subtar in unpack_dir.iterdir(): subtar_unpack_dir = unpack_dir / subtar.stem subtar_unpack_dir.mkdir(parents=True, exist_ok=True) with tarfile.open(str(subtar), "r") as s: s.extractall(str(subtar_unpack_dir)) files = sorted(str(f.relative_to(subtar_unpack_dir)) for f in subtar_unpack_dir.iterdir()) assert sorted(expected_files[subtar.name]) == files, \ "Subtar %s has wrong files" % subtar.name