diff --git a/kubernetes_state/ci/fixtures/prometheus/protobuf.bin b/kubernetes_state/ci/fixtures/prometheus/protobuf.bin index 5bf70c42db860..25ddee8829e67 100644 Binary files a/kubernetes_state/ci/fixtures/prometheus/protobuf.bin and b/kubernetes_state/ci/fixtures/prometheus/protobuf.bin differ diff --git a/kubernetes_state/test_kubernetes_state.py b/kubernetes_state/test_kubernetes_state.py index 7771ce3b9418b..749cd5b3fee5f 100644 --- a/kubernetes_state/test_kubernetes_state.py +++ b/kubernetes_state/test_kubernetes_state.py @@ -16,26 +16,51 @@ class TestKubernetesState(AgentCheckTest): CHECK_NAME = 'kubernetes_state' METRICS = [ - NAMESPACE + '.node.cpu_capacity', - NAMESPACE + '.node.memory_capacity', - NAMESPACE + '.node.pods_capacity', - NAMESPACE + '.node.cpu_allocatable', - NAMESPACE + '.node.memory_allocatable', - NAMESPACE + '.node.pods_allocatable', - NAMESPACE + '.node.status', - NAMESPACE + '.container.cpu_requested', - NAMESPACE + '.container.memory_requested', - NAMESPACE + '.container.cpu_limit', - NAMESPACE + '.container.memory_limit', - NAMESPACE + '.container.restarts', - NAMESPACE + '.deployment.replicas_available', - NAMESPACE + '.deployment.replicas_unavailable', - NAMESPACE + '.deployment.replicas_desired', - NAMESPACE + '.deployment.replicas_updated', - ] + # nodes + NAMESPACE + '.node.cpu_capacity', + NAMESPACE + '.node.memory_capacity', + NAMESPACE + '.node.pods_capacity', + NAMESPACE + '.node.cpu_allocatable', + NAMESPACE + '.node.memory_allocatable', + NAMESPACE + '.node.pods_allocatable', + # deployments + NAMESPACE + '.deployment.replicas', + NAMESPACE + '.deployment.replicas_available', + NAMESPACE + '.deployment.replicas_unavailable', + NAMESPACE + '.deployment.replicas_updated', + NAMESPACE + '.deployment.replicas_desired', + NAMESPACE + '.deployment.paused', + NAMESPACE + '.deployment.rollingupdate.max_unavailable', + # daemonsets + NAMESPACE + '.daemonset.scheduled', + NAMESPACE + '.daemonset.misscheduled', + NAMESPACE + '.daemonset.desired', + # pods + NAMESPACE + '.pod.ready', + NAMESPACE + '.pod.scheduled', + NAMESPACE + '.pod.container.ready', + NAMESPACE + '.pod.container.running', + NAMESPACE + '.pod.container.terminated', + NAMESPACE + '.pod.container.waiting', + NAMESPACE + '.container.restarts', + NAMESPACE + '.container.cpu_requested', + NAMESPACE + '.container.memory_requested', + NAMESPACE + '.container.cpu_limit', + NAMESPACE + '.container.memory_limit', + # replicasets + NAMESPACE + '.replicaset.replicas', + NAMESPACE + '.replicaset.fully_labeled_replicas', + NAMESPACE + '.replicaset.replicas_ready', + NAMESPACE + '.replicaset.replicas_desired', + ] ZERO_METRICS = [ NAMESPACE + '.deployment.replicas_unavailable', + NAMESPACE + '.deployment.paused', + NAMESPACE + '.daemonset.misscheduled', + NAMESPACE + '.pod.container.terminated', + NAMESPACE + '.pod.container.waiting', + ] def test__get_kube_state(self): @@ -93,13 +118,22 @@ def test__update_kube_state_metrics(self): self.assertServiceCheck(NAMESPACE + '.node.ready', self.check.OK) self.assertServiceCheck(NAMESPACE + '.node.out_of_disk', self.check.OK) self.assertServiceCheck(NAMESPACE + '.pod.phase.running', self.check.OK) - self.assertServiceCheck(NAMESPACE + '.pod.phase.failed', self.check.CRITICAL) + self.assertServiceCheck(NAMESPACE + '.pod.phase.pending', self.check.WARNING) # TODO: uncomment when any of these are in the test protobuf.bin - # self.assertServiceCheck(NAMESPACE + '.pod.phase.pending', self.check.WARNING) # self.assertServiceCheck(NAMESPACE + '.pod.phase.succeeded', self.check.OK) + # self.assertServiceCheck(NAMESPACE + '.pod.phase.failed', self.check.CRITICAL) # self.assertServiceCheck(NAMESPACE + '.pod.phase.unknown', self.check.UNKNOWN) for metric in self.METRICS: self.assertMetric(metric) if metric not in self.ZERO_METRICS: self.assertMetricNotAllZeros(metric) + + self.assert_resourcequota() + + def assert_resourcequota(self): + """ The metric name is created dynamically so we just check some exist. """ + for m in self.metrics: + if 'kubernetes_state.resourcequota.' in m[0]: + return True + return False