Commit 606fec17 authored by Maarten de Waard's avatar Maarten de Waard
Browse files

Merge branch '379-ignore-kubejobcompletion-kubejobfailed' into 'master'

Ignore failing pods and jobs from NC installation

Closes #379

See merge request openappstack/openappstack!184
parents 116c222b 1745a5dd
import json
import pytest
import requests
import re
def test_prometheus_alerts(host):
def summarize_alerts(alerts):
"""Print a alert summary."""
print('Total alerts: %s' % len(alerts))
print(json.dumps(alerts, indent=2))
print("Starting prometheus test...")
......@@ -12,15 +17,37 @@ def test_prometheus_alerts(host):
status = alert_json["status"]
alerts = alert_json["data"]["alerts"]
# Filter out the ever firing "Dead mans switch"
real_alerts = [alert for alert in alerts
if alert["labels"]["severity"] != "none"]
real_alerts = []
ignored_alerts = []
for alert in alerts:
# Filter out the ever firing "Dead mans switch" test alert
if (alert["labels"]["severity"] == "none" or \
# Filter out failing Nextcloud installation jobs since a lot of
# them fail until they succeed during installation
alert["labels"]["alertname"]) and
"nextcloud" in alert["labels"]["job_name"]) or
# Filter out failing Nextcloud pods since a lot of pods fail
# during installation
# We use python-behave tests to check for functionality
alert["labels"]["alertname"]) and
"nextcloud" in alert["labels"]["pod"])):
print('\n\n\n========= Ignored ==========')
print('\n\n\n========= Firing ==========')
alert_names = list(map(lambda alert: alert["labels"]["alertname"], real_alerts))
count = len(real_alerts)
assert status == "success", "Failure queriying the prometheus api at" + url
assert count == 0, "Firing alerts: {0}".format(str(alert_names))
assert count == 0, "Firing alerts: {0}".format(count)
if __name__ == "__main__":
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment