grafana/pkg/services/sqlstore/migrations/ualert/testing.go
Matthew Jacobson 0301d956da
Alerting: Create fewer contact points on migration (#47291)
* Alerting: Create fewer contact points on migration

Previously a new contact point was created for every unique combination
of channels attached to any legacy alert. This was very hard to maintain,
requiring modifications in every generated contact point.

This change deduplicates the generated contact points to a more
reasonable state. There should now only be one contact point per legacy
channel, and we attached multiple contact points to a route by nesting
them. The sole exception to this is if there were multiple default
legacy channels, in which case we create a redundant contact point
containing all of them used only in the root policy. This allows for a
much simpler notification policy structure.

Co-authored-by: gotjosh <josue.abreu@gmail.com>
2022-04-26 16:17:30 +02:00

22 lines
404 B
Go

package ualert
import (
"testing"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
)
// newTestMigration generates an empty migration to use in tests.
func newTestMigration(t *testing.T) *migration {
t.Helper()
return &migration{
mg: &migrator.Migrator{
Logger: log.New("test"),
},
seenChannelUIDs: make(map[string]struct{}),
}
}