eafc8ab1cd
We have two historians in alerting - alert state and notification. The intention of this app is to provide query capabilities for both. In this initial commit, the existing /history API is simply cloned to the new app. It is identical except that it will send Kubernetes-style error responses instead of Grafana-style. This approach was taken to implement the new app more iteratively - ideally we would define a new API, but this requires quite a significant overhaul of the backend code.
55 lines
2.3 KiB
Go
55 lines
2.3 KiB
Go
package appregistry
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/grafana/grafana/pkg/registry/apps/advisor"
|
|
"github.com/grafana/grafana/pkg/registry/apps/alerting/historian"
|
|
"github.com/grafana/grafana/pkg/registry/apps/alerting/notifications"
|
|
"github.com/grafana/grafana/pkg/registry/apps/alerting/rules"
|
|
"github.com/grafana/grafana/pkg/registry/apps/annotation"
|
|
"github.com/grafana/grafana/pkg/registry/apps/correlations"
|
|
"github.com/grafana/grafana/pkg/registry/apps/example"
|
|
"github.com/grafana/grafana/pkg/registry/apps/playlist"
|
|
"github.com/grafana/grafana/pkg/registry/apps/plugins"
|
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
|
)
|
|
|
|
func TestProvideAppInstallers_Table(t *testing.T) {
|
|
playlistInstaller := &playlist.PlaylistAppInstaller{}
|
|
pluginsInstaller := &plugins.AppInstaller{}
|
|
rulesInstaller := &rules.AlertingRulesAppInstaller{}
|
|
correlationsAppInstaller := &correlations.AppInstaller{}
|
|
notificationsAppInstaller := ¬ifications.AlertingNotificationsAppInstaller{}
|
|
annotationAppInstaller := &annotation.AnnotationAppInstaller{}
|
|
exampleAppInstaller := &example.ExampleAppInstaller{}
|
|
advisorAppInstaller := &advisor.AdvisorAppInstaller{}
|
|
historianAppInstaller := &historian.AlertingHistorianAppInstaller{}
|
|
|
|
tests := []struct {
|
|
name string
|
|
flags []any
|
|
rulesInst *rules.AlertingRulesAppInstaller
|
|
expectRulesApp bool
|
|
}{
|
|
{name: "no flags", flags: nil, rulesInst: nil, expectRulesApp: false},
|
|
{name: "rules flag without installer", flags: []any{featuremgmt.FlagKubernetesAlertingRules}, rulesInst: nil, expectRulesApp: false},
|
|
{name: "rules flag with installer", flags: []any{featuremgmt.FlagKubernetesAlertingRules}, rulesInst: rulesInstaller, expectRulesApp: true},
|
|
{name: "rules installer without flag", flags: nil, rulesInst: rulesInstaller, expectRulesApp: false},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
features := featuremgmt.WithFeatures(tt.flags...)
|
|
got := ProvideAppInstallers(features, playlistInstaller, pluginsInstaller, nil, tt.rulesInst, correlationsAppInstaller, notificationsAppInstaller, nil, annotationAppInstaller, exampleAppInstaller, advisorAppInstaller, historianAppInstaller)
|
|
if tt.expectRulesApp {
|
|
require.Contains(t, got, tt.rulesInst)
|
|
} else {
|
|
require.NotContains(t, got, tt.rulesInst)
|
|
}
|
|
})
|
|
}
|
|
}
|