I have below prometheus unit test
I tried a lot of manipulations on input_series. But it is always throwing failure.
It only evaluates the first value in the input series.
Unit Testing: tests/infra_db_alerts-tests.yml
FAILED:
alertname: MySQLReplicationDown, time: 10m,
exp:[
0:
Labels:{alert_owner="alerts-infra", alertname="MySQLReplicationDown", severity="High"}
Annotations:{description="MySQL replication is broken. \n"}
],
got:[]
rule_files:
- ../rules/db_alerts.yml
tests:
# MySQL Alert Tests
- input_series:
- series: mysql_up
values: 0
- series: mysql_global_variables_innodb_replication_delay
values: '1 1 1 1 1 0 0 0 0 -1 -1 -1 -1 -1 -1'
alert_rule_test:
- alertname: MySQLReplicationLag
eval_time: 5m
exp_alerts:
- exp_labels:
severity: High
alert_owner: alerts-infra
exp_annotations:
description: "There is a MySQL replication delay. \n"
- alertname: MySQLReplicationDown
eval_time: 10m
exp_alerts:
- exp_labels:
severity: High
alert_owner: alerts-infra
exp_annotations:
description: "MySQL replication is broken. \n"