示例#1
0
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)
示例#2
0
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.paths  # pylint: disable=import-outside-toplevel
    import cmk.utils.version as cmk_version  # pylint: disable=import-outside-toplevel

    if is_managed_repo():
        edition_short = "cme"
    elif is_enterprise_repo():
        edition_short = "cee"
    else:
        edition_short = "cre"

    monkeypatch.setattr(
        cmk_version, "omd_version", lambda: "%s.%s" %
        (cmk_version.__version__, edition_short))

    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.trusted_ca_file",
                        os.path.join(tmp_dir, "var/ssl/ca-certificates.crt"))
    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.log_dir",
                        os.path.join(tmp_dir, "var/log"))
    monkeypatch.setattr("cmk.utils.paths.core_helper_config_dir",
                        Path(tmp_dir, "var/check_mk/core/helper_config"))
    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"))
    monkeypatch.setattr("cmk.utils.paths.diagnostics_dir",
                        Path(tmp_dir).joinpath("var/check_mk/diagnostics"))
    monkeypatch.setattr("cmk.utils.paths.site_config_dir",
                        Path(cmk.utils.paths.var_dir, "site_configs"))
    monkeypatch.setattr("cmk.utils.paths.disabled_packages_dir",
                        Path(cmk.utils.paths.var_dir, "disabled_packages"))
    monkeypatch.setattr(
        "cmk.utils.paths.nagios_objects_file",
        os.path.join(tmp_dir, "etc/nagios/conf.d/check_mk_objects.cfg"),
    )
    monkeypatch.setattr(
        "cmk.utils.paths.precompiled_hostchecks_dir",
        os.path.join(tmp_dir, "var/check_mk/precompiled"),
    )
    monkeypatch.setattr(
        "cmk.utils.paths.discovered_host_labels_dir",
        Path(tmp_dir, "var/check_mk/discovered_host_labels"),
    )
    monkeypatch.setattr("cmk.utils.paths.profile_dir",
                        Path(cmk.utils.paths.var_dir, "web"))
示例#3
0
def test_generate_pre_17_site_snapshot(edition_short, monkeypatch, tmp_path,
                                       with_user_login, remote_site):
    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(utils, "is_pre_17_remote_site",
                        lambda s: is_pre_17_site)

    activation_manager = _get_activation_manager(monkeypatch, remote_site)
    snapshot_settings = _create_sync_snapshot(
        activation_manager,
        snapshot_data_collector_class,
        monkeypatch,
        tmp_path,
        is_pre_17_site,
        remote_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 config.sites[remote_site].get("replicate_mkps", False):
        expected_subtars += [
            "local.tar",
            "mkps.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: Dict[str, List[str]] = {
        "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": [],
    }

    if config.sites[remote_site].get("replicate_mkps", False):
        expected_files.update({"local.tar": [], "mkps.tar": []})

    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)
示例#4
0
def _get_expected_paths(user_id, is_pre_17_site, with_local):
    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",
        "var/check_mk/web/%s" % user_id,
        "var/check_mk/web/%s/cached_profile.mk" % user_id,
        "var/check_mk/web/%s/enforce_pw_change.mk" % user_id,
        "var/check_mk/web/%s/last_pw_change.mk" % user_id,
        "var/check_mk/web/%s/num_failed_logins.mk" % user_id,
        "var/check_mk/web/%s/serial.mk" % user_id,
    ]

    if with_local:
        expected_paths += [
            "local",
            "var/check_mk/packages",
        ]

    # 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
示例#5
0
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.paths  # pylint: disable=import-outside-toplevel
    import cmk.utils.version as cmk_version  # pylint: disable=import-outside-toplevel

    if is_managed_repo():
        edition_short = "cme"
    elif is_plus_repo():
        edition_short = "cpe"
    elif is_enterprise_repo():
        edition_short = "cee"
    else:
        edition_short = "cre"

    monkeypatch.setattr(
        cmk_version, "omd_version", lambda: "%s.%s" %
        (cmk_version.__version__, edition_short))

    # Unit test context: load all available modules
    monkeypatch.setattr(
        cmk_version,
        "is_raw_edition",
        lambda: not (is_enterprise_repo() and is_managed_repo() and
                     is_plus_repo()),
    )
    monkeypatch.setattr(cmk_version, "is_enterprise_edition",
                        is_enterprise_repo)
    monkeypatch.setattr(cmk_version, "is_managed_edition", is_managed_repo)
    monkeypatch.setattr(cmk_version, "is_plus_edition", is_plus_repo)

    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.inventory_delta_cache_dir",
        os.path.join(tmp_dir, "var/check_mk/inventory_delta_cache"),
    )
    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", Path(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.trusted_ca_file",
                        Path(tmp_dir, "var/ssl/ca-certificates.crt"))
    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.log_dir",
                        os.path.join(tmp_dir, "var/log"))
    monkeypatch.setattr("cmk.utils.paths.core_helper_config_dir",
                        Path(tmp_dir, "var/check_mk/core/helper_config"))
    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_gui_plugins_dir",
                        Path(tmp_dir, "local/lib/check_mk/gui/plugins"))
    monkeypatch.setattr("cmk.utils.paths.local_mib_dir",
                        Path(tmp_dir, "local/share/snmp/mibs"))
    monkeypatch.setattr("cmk.utils.paths.diagnostics_dir",
                        Path(tmp_dir).joinpath("var/check_mk/diagnostics"))
    monkeypatch.setattr("cmk.utils.paths.site_config_dir",
                        Path(cmk.utils.paths.var_dir, "site_configs"))
    monkeypatch.setattr("cmk.utils.paths.disabled_packages_dir",
                        Path(cmk.utils.paths.var_dir, "disabled_packages"))
    monkeypatch.setattr(
        "cmk.utils.paths.nagios_objects_file",
        os.path.join(tmp_dir, "etc/nagios/conf.d/check_mk_objects.cfg"),
    )
    monkeypatch.setattr(
        "cmk.utils.paths.precompiled_hostchecks_dir",
        os.path.join(tmp_dir, "var/check_mk/precompiled"),
    )
    monkeypatch.setattr(
        "cmk.utils.paths.discovered_host_labels_dir",
        Path(tmp_dir, "var/check_mk/discovered_host_labels"),
    )
    monkeypatch.setattr("cmk.utils.paths.profile_dir",
                        Path(cmk.utils.paths.var_dir, "web"))

    # Agent registration paths
    monkeypatch.setattr(
        "cmk.utils.paths.received_outputs_dir",
        Path(cmk.utils.paths.var_dir, "agent-receiver/received-outputs"),
    )
    monkeypatch.setattr(
        "cmk.utils.paths.data_source_push_agent_dir",
        Path(cmk.utils.paths.data_source_cache_dir, "push-agent"),
    )
    monkeypatch.setattr(
        "cmk.utils.paths._r4r_base_dir",
        Path(cmk.utils.paths.var_dir, "wato/requests-for-registration"),
    )
    monkeypatch.setattr(
        "cmk.utils.paths.r4r_new_dir",
        Path(cmk.utils.paths._r4r_base_dir, "NEW"),
    )
    monkeypatch.setattr(
        "cmk.utils.paths.r4r_pending_dir",
        Path(cmk.utils.paths._r4r_base_dir, "PENDING"),
    )
    monkeypatch.setattr(
        "cmk.utils.paths.r4r_declined_dir",
        Path(cmk.utils.paths._r4r_base_dir, "DECLINED"),
    )
    monkeypatch.setattr(
        "cmk.utils.paths.r4r_declined_bundles_dir",
        Path(cmk.utils.paths._r4r_base_dir, "DECLINED-BUNDLES"),
    )
    monkeypatch.setattr(
        "cmk.utils.paths.r4r_ready_dir",
        Path(cmk.utils.paths._r4r_base_dir, "READY"),
    )
    monkeypatch.setattr(
        "cmk.utils.paths.r4r_discoverable_dir",
        Path(cmk.utils.paths._r4r_base_dir, "DISCOVERABLE"),
    )
示例#6
0
def test_dependencies_are_used() -> None:
    unused_packages = CEE_UNUSED_PACKAGES
    if not is_enterprise_repo():
        unused_packages += ["PyPDF3", "numpy", "roman"]
    assert sorted(get_unused_dependencies()) == sorted(unused_packages)
示例#7
0
    "s3transfer",
    "semver",
    "setuptools-git",
    "setuptools_scm",
    "snmpsim",
    "tenacity",
    "typing_extensions",
    "uvicorn",
    "websocket_client",
    "wrapt",
    "yarl",
    "zipp",
]


@pytest.mark.skipif(not is_enterprise_repo(), reason="Test is only for CEE")
def test_dependencies_are_used_cee() -> None:
    assert sorted(get_unused_dependencies()) == CEE_UNUSED_PACKAGES


@pytest.mark.skipif(is_enterprise_repo(), reason="Test is only for CRE")
def test_dependencies_are_used_cre() -> None:
    unused_packages = CEE_UNUSED_PACKAGES + [
        "PyPDF3",  # is only used in CEE
        "numpy",  # is only used in CEE
        "roman",  # is only used in CEE
    ]
    assert sorted(get_unused_dependencies()) == sorted(unused_packages)


def test_dependencies_are_declared() -> None: