Skip to content

Commit 5f12190

Browse files
authored
Adjust Alertmanager E2E verification to allow common alerts (#190)
* Adjust Alertmanager E2E verification to allow InfoInhibitor & PrometheusOutOfOrderTimestamps * Make helm repo url configurable * Simplify checks to verify based on count vs (count - expected)
1 parent 3f31dac commit 5f12190

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

Diff for: .github/workflows/e2e/scripts/install-monitoring.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ set -x
55
source $(dirname $0)/entry
66

77
HELM_REPO="rancher-charts"
8+
HELM_REPO_URL="https://charts.rancher.io"
89

910
cd $(dirname $0)/../../../..
1011

1112
helm version
1213

13-
helm repo add ${HELM_REPO} https://charts.rancher.io
14+
helm repo add ${HELM_REPO} $HELM_REPO_URL
1415
helm repo update
1516

1617
echo "Create required \`cattle-fleet-system\` namespace"

Diff for: .github/workflows/e2e/scripts/validate-project-alertmanager.sh

+13-12
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,25 @@ while true; do
3535
exit 1
3636
fi
3737

38-
if [[ $(yq '. | length' "${tmp_alerts_yaml}") != "1" ]]; then
39-
echo "ERROR: Found the wrong number of alerts in Project Alertmanager, expected only 'Watchdog'"
38+
ALERT_COUNT=$(yq '. | length' "${tmp_alerts_yaml}")
39+
if [[ $ALERT_COUNT -gt 3 ]]; then
40+
echo "ERROR: Found too many alerts in Project Alertmanager. Expected at most: 'Watchdog', 'InfoInhibitor' and/or 'PrometheusOutOfOrderTimestamps'."
4041
cat "${tmp_alerts_yaml}"
4142

42-
echo "Retrying in $DEFAULT_SLEEP_TIMEOUT_SECONDS seconds..."
43-
sleep "$DEFAULT_SLEEP_TIMEOUT_SECONDS"
44-
continue
43+
echo "Retrying in $DEFAULT_SLEEP_TIMEOUT_SECONDS seconds..."
44+
sleep "$DEFAULT_SLEEP_TIMEOUT_SECONDS"
45+
continue
4546
fi
4647
CHECKS_PASSED=$((CHECKS_PASSED+1))
4748

49+
UNEXPECTED_COUNT=$(yq '[.[] | select(.labels.alertname != "Watchdog" and .labels.alertname != "InfoInhibitor" and .labels.alertname != "PrometheusOutOfOrderTimestamps")] | length' "${tmp_alerts_yaml}")
50+
if [[ $UNEXPECTED_COUNT -gt 0 ]]; then
51+
echo "ERROR: Unexpected alert(s) found in active alerts list."
52+
cat "${tmp_alerts_yaml}"
4853

49-
if [[ $(yq '.[0].labels.alertname' "${tmp_alerts_yaml}") != "Watchdog" ]]; then
50-
echo "ERROR: Expected the only alert to be triggered on the Project Alertmanager to be 'Watchdog'"
51-
cat "${tmp_alerts_yaml}"
52-
53-
echo "Retrying in $DEFAULT_SLEEP_TIMEOUT_SECONDS seconds..."
54-
sleep "$DEFAULT_SLEEP_TIMEOUT_SECONDS"
55-
continue
54+
echo "Retrying in $DEFAULT_SLEEP_TIMEOUT_SECONDS seconds..."
55+
sleep "$DEFAULT_SLEEP_TIMEOUT_SECONDS"
56+
continue
5657
fi
5758
CHECKS_PASSED=$((CHECKS_PASSED+1))
5859

0 commit comments

Comments
 (0)