コード例 #1
0
ファイル: test_summarizers.py プロジェクト: gradecke/checkmk
 def summarizer(self):
     return AgentSummarizerDefault(
         ExitSpec(),
         is_cluster=False,
         agent_min_version=0,
         agent_target_version=None,
         only_from=["deep_space"],
     )
コード例 #2
0
 def _make_summarizer(self) -> AgentSummarizerDefault:
     return AgentSummarizerDefault(
         self.exit_spec,
         is_cluster=self.host_config.is_cluster,
         agent_min_version=config.agent_min_version,
         agent_target_version=self.host_config.agent_target_version,
         only_from=self.host_config.only_from,
     )
コード例 #3
0
ファイル: test_summarizers.py プロジェクト: gradecke/checkmk
 def summarizer(self, request):
     return AgentSummarizerDefault(
         ExitSpec(),
         is_cluster=False,
         agent_min_version=0,
         agent_target_version=request.param,
         only_from=None,
     )
コード例 #4
0
def test_tcpdatasource_restricted_address_mismatch(
    monkeypatch,
    restricted_address_mismatch_state,
    only_from,
    rule,
    res,
):
    # TODO(ml): Not only is this white box testing but all these instantiations
    #           before the summarizer obscure the purpose of the test.  This is
    #           way too complicated.  Test the `AgentSummarizerDefault` directly
    #           in `tests.unit.cmk.core_helpers.test_summarizers` instead.
    hostname = HostName("hostname")

    ts = Scenario().add_host(hostname)
    ts.set_option("agent_config",
                  {"only_from": [(rule, [], [str(hostname)], {})]})

    if restricted_address_mismatch_state is not None:
        ts.set_ruleset(
            "check_mk_exit_status",
            [
                (
                    {
                        "restricted_address_mismatch":
                        restricted_address_mismatch_state,
                    },
                    [],
                    [str(hostname)],
                    {},
                ),
            ],
        )

    ts.apply(monkeypatch)
    source = TCPSource(hostname, "ipaddress")

    summarizer = AgentSummarizerDefault(
        source.exit_spec,
        is_cluster=source.host_config.is_cluster,
        agent_min_version=0,
        agent_target_version=source.host_config.agent_target_version,
        only_from=source.host_config.only_from,
    )

    assert summarizer._check_only_from(only_from) == res
コード例 #5
0
def test_tcpdatasource_only_from(mode, monkeypatch, res, reported, rule):
    # TODO(ml): Not only is this white box testing but all these instantiations
    #           before the summarizer obscure the purpose of the test.  This is
    #           way too complicated.  Test the `AgentSummarizerDefault` directly
    #           in `tests.unit.cmk.core_helpers.test_summarizers` instead.
    ts = Scenario().add_host("hostname")
    ts.set_option("agent_config", {"only_from": [rule]} if rule else {})
    config_cache = ts.apply(monkeypatch)

    source = TCPSource("hostname", "ipaddress", mode=mode)
    monkeypatch.setattr(config_cache, "host_extra_conf",
                        lambda host, ruleset: ruleset)

    summarizer = AgentSummarizerDefault(
        source.exit_spec,
        is_cluster=source.host_config.is_cluster,
        agent_min_version=0,
        agent_target_version=source.host_config.agent_target_version,
        only_from=source.host_config.only_from,
    )
    assert summarizer._check_only_from(reported) == res
コード例 #6
0
 def test_configure_missmatch(self, mode, state):
     assert (AgentSummarizerDefault(
         ExitSpec(restricted_address_mismatch=state),
         is_cluster=False,
         agent_min_version=0,
         agent_target_version=None,
         only_from=["deep_space"],
     ).summarize_check_mk_section(
         [
             ["onlyfrom:", "somewhere_else"],
         ],
         mode=mode,
     )[0].state == state)
コード例 #7
0
 def summarizer(self):
     return AgentSummarizerDefault(ExitSpec())
コード例 #8
0
ファイル: tcp.py プロジェクト: LinuxHaus/checkmk
 def _make_summarizer(self) -> AgentSummarizerDefault:
     return AgentSummarizerDefault(self.exit_spec)