From 48ab110e09c8bbaa7f12f2667032ac1a86b5a6f8 Mon Sep 17 00:00:00 2001
From: Golubkov Igor <igor.golubkov@alp.ru>
Date: Thu, 22 Nov 2018 17:25:36 +0300
Subject: [PATCH] Update unit tests

---
 jsonnet/kube-prometheus/alerts/tests.yaml | 113 ++++++++++++++++++++++
 1 file changed, 113 insertions(+)

diff --git a/jsonnet/kube-prometheus/alerts/tests.yaml b/jsonnet/kube-prometheus/alerts/tests.yaml
index 8cfc3aa7..532bb895 100644
--- a/jsonnet/kube-prometheus/alerts/tests.yaml
+++ b/jsonnet/kube-prometheus/alerts/tests.yaml
@@ -24,6 +24,10 @@ tests:
           - exp_labels:
               service: 'alertmanager-main'
               severity: critical
+              job: 'alertmanager-main'
+              instance: 10.10.10.0
+              namespace: monitoring
+              pod: alertmanager-main-0
             exp_annotations:
               message: 'Alertmanager has not found all other members of the cluster.'
       - eval_time: 17m
@@ -32,6 +36,10 @@ tests:
           - exp_labels:
               service: 'alertmanager-main'
               severity: critical
+              job: 'alertmanager-main'
+              instance: 10.10.10.0
+              namespace: monitoring
+              pod: alertmanager-main-0
             exp_annotations:
               message: 'Alertmanager has not found all other members of the cluster.'
       - eval_time: 23m
@@ -40,5 +48,110 @@ tests:
           - exp_labels:
               service: 'alertmanager-main'
               severity: critical
+              job: 'alertmanager-main'
+              instance: 10.10.10.0
+              namespace: monitoring
+              pod: alertmanager-main-0
+            exp_annotations:
+              message: 'Alertmanager has not found all other members of the cluster.'
+  - interval: 1m
+    input_series:
+      - series: 'alertmanager_cluster_members{job="alertmanager-main",instance="10.10.10.0",namespace="monitoring",pod="alertmanager-main-0",service="alertmanager-main"}'
+        values: '3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+      - series: 'alertmanager_cluster_members{job="alertmanager-main",instance="10.10.10.1",namespace="monitoring",pod="alertmanager-main-1",service="alertmanager-main"}'
+        values: '3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2'
+      - series: 'alertmanager_cluster_members{job="alertmanager-main",instance="10.10.10.2",namespace="monitoring",pod="alertmanager-main-2",service="alertmanager-main"}'
+        values: '3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2'
+    alert_rule_test:
+      - eval_time: 5m
+        alertname: AlertmanagerMembersInconsistent
+      - eval_time: 11m
+        alertname: AlertmanagerMembersInconsistent
+        exp_alerts:
+          - exp_labels:
+              service: 'alertmanager-main'
+              severity: critical
+              job: 'alertmanager-main'
+              instance: 10.10.10.0
+              namespace: monitoring
+              pod: alertmanager-main-0
+            exp_annotations:
+              message: 'Alertmanager has not found all other members of the cluster.'
+          - exp_labels:
+              service: 'alertmanager-main'
+              severity: critical
+              job: 'alertmanager-main'
+              instance: 10.10.10.1
+              namespace: monitoring
+              pod: alertmanager-main-1
+            exp_annotations:
+              message: 'Alertmanager has not found all other members of the cluster.'
+          - exp_labels:
+              service: 'alertmanager-main'
+              severity: critical
+              job: 'alertmanager-main'
+              instance: 10.10.10.2
+              namespace: monitoring
+              pod: alertmanager-main-2
+            exp_annotations:
+              message: 'Alertmanager has not found all other members of the cluster.'
+      - eval_time: 17m
+        alertname: AlertmanagerMembersInconsistent
+        exp_alerts:
+          - exp_labels:
+              service: 'alertmanager-main'
+              severity: critical
+              job: 'alertmanager-main'
+              instance: 10.10.10.0
+              namespace: monitoring
+              pod: alertmanager-main-0
+            exp_annotations:
+              message: 'Alertmanager has not found all other members of the cluster.'
+          - exp_labels:
+              service: 'alertmanager-main'
+              severity: critical
+              job: 'alertmanager-main'
+              instance: 10.10.10.1
+              namespace: monitoring
+              pod: alertmanager-main-1
+            exp_annotations:
+              message: 'Alertmanager has not found all other members of the cluster.'
+          - exp_labels:
+              service: 'alertmanager-main'
+              severity: critical
+              job: 'alertmanager-main'
+              instance: 10.10.10.2
+              namespace: monitoring
+              pod: alertmanager-main-2
+            exp_annotations:
+              message: 'Alertmanager has not found all other members of the cluster.'
+      - eval_time: 23m
+        alertname: AlertmanagerMembersInconsistent
+        exp_alerts:
+          - exp_labels:
+              service: 'alertmanager-main'
+              severity: critical
+              job: 'alertmanager-main'
+              instance: 10.10.10.0
+              namespace: monitoring
+              pod: alertmanager-main-0
+            exp_annotations:
+              message: 'Alertmanager has not found all other members of the cluster.'
+          - exp_labels:
+              service: 'alertmanager-main'
+              severity: critical
+              job: 'alertmanager-main'
+              instance: 10.10.10.1
+              namespace: monitoring
+              pod: alertmanager-main-1
+            exp_annotations:
+              message: 'Alertmanager has not found all other members of the cluster.'
+          - exp_labels:
+              service: 'alertmanager-main'
+              severity: critical
+              job: 'alertmanager-main'
+              instance: 10.10.10.2
+              namespace: monitoring
+              pod: alertmanager-main-2
             exp_annotations:
               message: 'Alertmanager has not found all other members of the cluster.'
-- 
GitLab