示例#1
0
    def test_empty_configmap(self, aggregator, mock_read_configmap, mock_incluster):
        mock_read_configmap.return_value = make_fake_object()
        c = KubeLeaderElectionBaseCheck()
        c.check(CM_INSTANCE)

        assert len(c.get_warnings()) == 1
        aggregator.assert_all_metrics_covered()
示例#2
0
    def test_invalid_configmap(self, aggregator, mock_read_configmap, mock_incluster):
        mock_read_configmap.return_value = make_fake_object(make_record(holder="me"))
        c = KubeLeaderElectionBaseCheck()
        c.check(CM_INSTANCE)

        assert c.get_warnings() == []
        aggregator.assert_service_check("base.leader_election.status", status=AgentCheck.CRITICAL, tags=CM_TAGS)
        aggregator.assert_all_metrics_covered()
 def test_config_kubeconfig(self, datadog_agent, config):
     datadog_agent.get_config.return_value = "/file/path"
     c = KubeLeaderElectionBaseCheck()
     c.check({})
     datadog_agent.get_config.assert_called_once_with(
         'kubernetes_kubeconfig_path')
     config.load_kube_config.assert_called_once_with(
         config_file="/file/path")
示例#4
0
    def test_valid_configmap(self, aggregator, mock_read_configmap, mock_incluster):
        mock_read_configmap.return_value = make_fake_object(RAW_VALID_RECORD)
        c = KubeLeaderElectionBaseCheck()
        c.check(CM_INSTANCE)

        assert c.get_warnings() == []
        mock_read_configmap.assert_called_once_with("thisrecord", "myns", _request_timeout=30)
        aggregator.assert_metric("base.leader_election.transitions", value=7, tags=CM_TAGS)
        aggregator.assert_metric("base.leader_election.lease_duration", value=60, tags=CM_TAGS)
        aggregator.assert_service_check("base.leader_election.status", status=AgentCheck.CRITICAL, tags=CM_TAGS)
        aggregator.assert_all_metrics_covered()
示例#5
0
    def test_ok_configmap(self, aggregator, mock_read_configmap, mock_incluster):
        mock_read_configmap.return_value = make_fake_object(
            make_record(holder="me", duration=30, renew=datetime.utcnow(), acquire="2018-12-18T12:32:22Z")
        )
        c = KubeLeaderElectionBaseCheck()
        c.check(CM_INSTANCE)

        assert c.get_warnings() == []
        aggregator.assert_metric("base.leader_election.transitions", value=0, tags=CM_TAGS)
        aggregator.assert_metric("base.leader_election.lease_duration", value=30, tags=CM_TAGS)
        aggregator.assert_service_check("base.leader_election.status", status=AgentCheck.OK, tags=CM_TAGS)
        aggregator.assert_all_metrics_covered()
示例#6
0
 def test_config_incluster(self, config):
     c = KubeLeaderElectionBaseCheck()
     c.check({})
     config.load_incluster_config.assert_called_once()