prometheus / compliance

A set of tests to check compliance with various Prometheus interfaces
Apache License 2.0
127 stars 44 forks source link

Epic: Alert Generator Compliance Test Suite #54

Closed codesome closed 2 years ago

codesome commented 2 years ago

Based on the specification, here is the list of all the high-level cases that needs to be covered by the test suite. In all the cases, the content of the alerts, APIs, time series, are checked to be correct.

All the time comparison will be done within a certain acceptable delta and need not be exact.

codesome commented 2 years ago

cc @RichiH

RichiH commented 2 years ago

I tried to find corner cases and thought I had them a few times, but in the end couldn't find any; this seems like good coverage.

Conceptually, I think it would make sense to group the tests:

It might make sense to visualize a state machine to make reasoning and verification that all possible states are covered easier.

codesome commented 2 years ago

Yup, I plan to have the least number of rules possible that can test all the above cases within a time bound.

codesome commented 2 years ago

Added another case

gotjosh commented 2 years ago

One extra case to test is that annotations can depend on user-defined labels. e.g. define a rule with a custom label of env={{ $labels.namespace }} and then have an annotation that uses this label e.g. summary=the env should be {{ $labels.env }}

Assuming the alert had a namespace of eu-west-0 it should come out as alertname=myalert,namespace=eu-west-0,env=eu-west-0,summary=the env should be eu-west-0

codesome commented 2 years ago

One extra case to test is that annotations can depend on user-defined labels.

I think that is not the case. I just tried it out with Prometheus and verified how we do it in the code, we only take the labels from the query result to expand the template. And even if we override the labels in the rule, the template expansion will still take the original label from the query.

Here is the example (notice instance and test in labels and its use in annotations):

Screenshot from 2021-11-25 15-27-22

But thanks for bringing it up, we will need test case to verify this behaviour and also update the spec.

codesome commented 2 years ago

Spec has this

The labels and annotation templates from the alerting rule MUST be run for each of these alerts individually with label-value data for the template coming from the corresponding element from the result vector.

So looks like we are all good

codesome commented 2 years ago

:tada: all the cases and template variables should be covered at this point. I have excluded the template variables that are only used in template files.

There are few things still remaining to make the test suite usable. I will create new issues for them.