diff --git a/test/pytest/test_prometheus.py b/test/pytest/test_prometheus.py index 05f00bceb1afbf8a40840a015f3a4970d14d2bca..b59ab572c3d8c814d4b0e878bdc4ff8834e5393c 100755 --- a/test/pytest/test_prometheus.py +++ b/test/pytest/test_prometheus.py @@ -1,5 +1,6 @@ import json import pytest +import re @pytest.mark.prometheus @@ -49,27 +50,48 @@ def ignore_alert(alert): Returns true if an alert should be ignored. This is when the "severity" equals "none", or in some application specific cases. """ + if alert["labels"]["severity"] == "none": return True + # Ignore `KubeAPILatencyHigh` fom high load during installation # phase if alert["labels"]["alertname"] == "KubeAPILatencyHigh": return True - # Filter out failing Nextcloud installation jobs since a lot of - # them fail until they succeed during installation - if "nextcloud" in alert["labels"]["pod"]: - if alert["labels"]["alertname"] in [ - "KubeJobFailed", - "KubeJobCompletion", - "KubePodNotReady"]: - return True - # Filter out when RocketChat pods take very long to start - if "rocketchat" in alert["labels"]["pod"]: - if alert["labels"]["alertname"] in [ - "KubePodNotReady", - "KubeDeploymentReplicasMismatch", - "KubeStatefulSetReplicasMismatch"]: - return True + + if 'pod' in alert["labels"]: + # Filter out failing Nextcloud installation jobs since a lot of + # them fail until they succeed during installation + if "nextcloud" in alert["labels"]["pod"]: + if alert["labels"]["alertname"] in [ + "KubeJobFailed", + "KubeJobCompletion", + "KubePodNotReady"]: + return True + + # Filter out when some apps take too long to start + if re.search("(rocketchat|wordpress)", alert["labels"]["pod"]): + if alert["labels"]["alertname"] in [ + "KubePodNotReady", + "KubeDeploymentReplicasMismatch", + "KubeStatefulSetReplicasMismatch"]: + return True + + # Filter out failed signgle-sign-on pods until we fix + # https://open.greenhost.net/openappstack/single-sign-on/issues/26 + if "single-sign-on-create-" in alert["labels"]["pod"]: + if alert["labels"]["alertname"] in ["KubePodNotReady"]: + return True + + if 'job_name' in alert["labels"]: + # Filter out failed signgle-sign-on jobs until we fix + # https://open.greenhost.net/openappstack/single-sign-on/issues/26 + if "single-sign-on-create-" in alert["labels"]["job_name"]: + if alert["labels"]["alertname"] in [ + "KubeJobFailed", + "KubeJobCompletion"]: + return True + return False