示例#1
0
def test_get_replication_components(edition_short, monkeypatch, replicate_ec,
                                    replicate_mkps):
    monkeypatch.setattr(cmk_version, "edition_short", lambda: edition_short)

    partial_site_config = {}
    if replicate_ec is not None:
        partial_site_config["replicate_ec"] = replicate_ec
    if replicate_mkps is not None:
        partial_site_config["replicate_mkps"] = replicate_mkps

    expected = _expected_replication_paths()

    if not replicate_ec:
        expected = [
            e for e in expected if e.ident not in ["mkeventd", "mkeventd_mkp"]
        ]

    if not replicate_mkps:
        expected = [e for e in expected if e.ident not in ["local", "mkps"]]

    work_dir = cmk.utils.paths.omd_root
    expected += [
        ReplicationPath(
            ty="file",
            ident="sitespecific",
            path="%s/site_globals/sitespecific.mk" % work_dir,
            excludes=[],
        )
    ]

    assert sorted(
        activate_changes._get_replication_components(
            work_dir, partial_site_config)) == sorted(expected)
示例#2
0
def test_get_replication_components(edition_short, monkeypatch, replicate_ec,
                                    replicate_mkps, is_pre_17_remote_site):
    partial_site_config = {}
    if replicate_ec is not None:
        partial_site_config["replicate_ec"] = replicate_ec
    if replicate_mkps is not None:
        partial_site_config["replicate_mkps"] = replicate_mkps

    expected = _expected_replication_paths()

    if not replicate_ec:
        expected = [
            e for e in expected if e.ident not in ["mkeventd", "mkeventd_mkp"]
        ]

    if not replicate_mkps:
        expected = [e for e in expected if e.ident not in ["local", "mkps"]]

    if is_pre_17_remote_site:
        for repl_path in expected:
            if repl_path.ident in {
                    "check_mk",
                    "multisite",
                    "liveproxyd",
                    "mkeventd",
                    "dcd",
                    "mknotify",
            }:
                if "sitespecific.mk" not in repl_path.excludes:
                    repl_path.excludes.append("sitespecific.mk")

            if repl_path.ident == "dcd" and "distributed.mk" not in repl_path.excludes:
                repl_path.excludes.append("distributed.mk")

        expected += [
            ReplicationPath(
                ty="file",
                ident="sitespecific",
                site_path="site_globals/sitespecific.mk",
                excludes=[],
            ),
        ]

    if not is_pre_17_remote_site:
        expected += [
            ReplicationPath(
                ty="file",
                ident="distributed_wato",
                site_path="etc/check_mk/conf.d/distributed_wato.mk",
                excludes=[".*new*"],
            ),
        ]

    assert sorted(
        activate_changes._get_replication_components(
            partial_site_config, is_pre_17_remote_site)) == sorted(expected)
示例#3
0
def test_get_replication_components(edition, monkeypatch, replicate_ec,
                                    replicate_mkps, is_pre_17_remote_site):
    partial_site_config = SiteConfiguration({})
    # Astroid 2.x bug prevents us from using NewType https://github.com/PyCQA/pylint/issues/2296
    # pylint: disable=unsupported-assignment-operation
    if replicate_ec is not None:
        partial_site_config["replicate_ec"] = replicate_ec
    if replicate_mkps is not None:
        partial_site_config["replicate_mkps"] = replicate_mkps

    expected = _expected_replication_paths()

    if not replicate_ec:
        expected = [
            e for e in expected if e.ident not in ["mkeventd", "mkeventd_mkp"]
        ]

    if not replicate_mkps:
        expected = [e for e in expected if e.ident not in ["local", "mkps"]]

    if is_pre_17_remote_site:
        for repl_path in expected:
            if repl_path.ident in {
                    "check_mk",
                    "multisite",
                    "liveproxyd",
                    "mkeventd",
                    "dcd",
                    "mknotify",
            }:
                if "sitespecific.mk" not in repl_path.excludes:
                    repl_path.excludes.append("sitespecific.mk")

            if repl_path.ident == "dcd" and "distributed.mk" not in repl_path.excludes:
                repl_path.excludes.append("distributed.mk")

        expected += [
            ReplicationPath(
                ty="file",
                ident="sitespecific",
                site_path="site_globals/sitespecific.mk",
                excludes=[],
            ),
        ]

    if not is_pre_17_remote_site:
        expected += [
            ReplicationPath(
                ty="file",
                ident="distributed_wato",
                site_path="etc/check_mk/conf.d/distributed_wato.mk",
                excludes=[".*new*"],
            ),
            ReplicationPath(
                ty="dir",
                ident="omd",
                site_path="etc/omd",
                excludes=["allocated_ports", "site.conf", ".*new*"],
            ),
        ]

    assert sorted(
        activate_changes._get_replication_components(
            partial_site_config, is_pre_17_remote_site)) == sorted(expected)