Alerting: Update alerting module + refactor (#111761)

* update alerting module
* replace compat with ones from alerting
* update type references Receiver and Integration to *Status
* update route in provisioning test that is invalid after recent change
* use right type for LINE ingtegration
This commit is contained in:
Yuri Tseretyan
2025-10-03 10:37:49 -04:00
committed by GitHub
parent cca9e0d55f
commit d0f79ee60d
25 changed files with 139 additions and 297 deletions
@@ -7,8 +7,12 @@ import (
"testing"
"github.com/google/go-cmp/cmp"
alertingmodels "github.com/grafana/alerting/models"
"github.com/grafana/alerting/notify"
"github.com/grafana/alerting/notify/notifytest"
"github.com/grafana/alerting/receivers/line"
receiversTesting "github.com/grafana/alerting/receivers/testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
apicompat "github.com/grafana/grafana/pkg/services/ngalert/api/compat"
@@ -53,12 +57,12 @@ func TestContactPointFromContactPointExports(t *testing.T) {
}
// use the configs for testing because they have all fields supported by integrations
for integrationType, cfg := range notify.AllKnownConfigsForTesting {
t.Run(integrationType, func(t *testing.T) {
for integrationType, cfg := range notifytest.AllKnownV1ConfigsForTesting {
t.Run(string(integrationType), func(t *testing.T) {
recCfg := &notify.APIReceiver{
ConfigReceiver: notify.ConfigReceiver{Name: "test-receiver"},
GrafanaIntegrations: notify.GrafanaIntegrations{
Integrations: []*notify.GrafanaIntegrationConfig{
ReceiverConfig: alertingmodels.ReceiverConfig{
Integrations: []*alertingmodels.IntegrationConfig{
cfg.GetRawNotifierConfig("test"),
},
},
@@ -87,9 +91,15 @@ func TestContactPointFromContactPointExports(t *testing.T) {
}
if integrationType != "webhook" {
// Many notifiers now support HTTPClientConfig but only Webhook currently has it enabled in schema.
//TODO: Remove this once HTTPClientConfig is added to other schemas.
// TODO: Remove this once HTTPClientConfig is added to other schemas.
pathFilters = append(pathFilters, "HTTPClientConfig")
}
if integrationType == line.Type {
for _, l := range actual.LineConfigs {
assert.Equal(t, "line", l.Type)
l.Type = string(line.Type)
}
}
pathFilter := cmp.FilterPath(func(path cmp.Path) bool {
for _, filter := range pathFilters {
if strings.Contains(path.String(), filter) {