grafana/pkg/tests
Matthew Jacobson 0c688190f7
Alerting: Fix unique violation when updating rule group with title chains/cycles (#67868)
* Alerting: Fix unique violation when updating rule group with title chains/cycles

The uniqueness constraint for titles within an org+folder is enforced on every update within a transaction instead of on commit (deferred constraint). This means that there could be a set of updates that will throw a unique constraint violation in an intermediate step even though the final state is valid. For example, a chain of updates RuleA -> RuleB -> RuleC could fail if not executed in the correct order, or a swap of titles RuleA <-> RuleB cannot be executed in any order without violating the constraint.

The exact solution to this is complex and requires determining directed paths and cycles in the update graph, adding in temporary updates to break cycles, and then executing the updates in reverse topological order (see first commit in PR if curious).

This is not implemented here.

Instead, we choose a simpler solution that works in all cases but might perform more updates than necessary. This simpler solution makes a determination of whether an intermediate collision could occur and if so, adds a temporary title on all updated rules to break any cycles and remove the need for specific ordering.

In addition, we make sure diffs are executed in the following order: DELETES, UPDATES, INSERTS.
2023-06-08 18:51:50 -04:00
..
api Alerting: Fix unique violation when updating rule group with title chains/cycles (#67868) 2023-06-08 18:51:50 -04:00
testinfra Auth: Use auth broker by default (#69620) 2023-06-07 08:57:41 +02:00
web Auth: Use auth broker by default (#69620) 2023-06-07 08:57:41 +02:00
README.md Chore: Add CloudWatch HTTP API tests (#29691) 2021-01-07 11:36:13 +01:00

Integration tests

This directory contains Grafana server integration tests.