mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 23:02:28 +08:00

* chore(angularsupport): delete feature toggle to disable angular * feat(angular-support): remove config.angularSupportEnabled * chore(jest): remove angular from setup file * chore(angular): delete angular deprecation ui components * refactor(angular): move migration featureflags into migration notice * chore(dashboard): remove angular deprecation notices * chore(annotations): remove angular editor loader * feat(appwrapper): no more angular app loading * feat(pluginscatalog): clean up angular plugin warnings and logic * chore(angular): delete angular app and associated files * feat(plugins): delete old angular graph plugin * feat(plugins): delete old angular table panel * feat(frontend): remove unused appEvent type * feat(dashboards): clean up angular from panel options and menu * feat(plugins): remove graph and table-old from built in plugins and delete sdk * feat(frontend): remove angular related imports in routes and explore graph * feat(theme): remove angular panel styles from global styles * chore(i18n): run make i18n-extract * test(api_plugins_test): refresh snapshot due to deleting old graph and table plugins * chore(angulardeprecation): delete angular migration notice components and usage * test(frontend): clean up tests that assert rendering angular deprecation notices * chore(backend): remove autoMigrateOldPanels feature flag * chore(config): remove angularSupportEnabled from config preventing loading angular plugins * chore(graphpanel): remove autoMigrateGraphPanel from feature toggles * chore(tablepanel): delete autoMigrateTablePanel feature flag * chore(piechart): delete autoMigratePiechartPanel feature flag * chore(worldmappanel): remove autoMigrateWorldmapPanel feature toggle * chore(statpanel): remove autoMigrateStatPanel feature flag * feat(dashboards): remove automigrate feature flags and always auto migrate angular panels * test(pluginsintegration): fix failing loader test * test(frontend): wip: fix failures and skip erroring migration tests * chore(codeowners): remove deleted angular related files and directories * test(graphite): remove angular mock from test file * test(dashboards): skip failing exporter test, remove angularSupportEnabled flags * test(dashbaord): skip another failing panel menu test * Tests: fixes pkg/services/pluginsintegration/loader/loader_test.go (#100505) * Tests: fixes pkg/services/pluginsintegration/plugins_integration_test.go * Trigger Build * chore(dashboards): remove angularComponent from getPanelMenu, update test * feat(dashboards): remove all usage of AngularComponent and getAngularLoader * chore(betterer): refresh results file * feat(plugins): remove PluginAngularBadge component and usage * feat(datasource_srv): remove usage of getLegacyAngularInjector * feat(queryeditor): delete AngularQueryComponentScope type * Chore: removes Angular from plugin_loader * Chore: remove angular from getPlugin * Chore: fix i18n * Trigger Build * Chore: remove more Angular from importPanelPlugin * Chore: remove search options warning * Chore: remove and deprecate Angular related * chore(angular): remove angular dependencies from core and runtime * chore(runtime): delete angular injector * chore(data): delete angular scope from event bus * chore(plugin-catalog): remove code pushing app plugins angular config page * chore(yarn): refresh lock file * chore(frontend): remove ng-loader from webpack configs, remove systemjs cjs plugin * chore(navigation): remove tether-drop cleanup from GrafanaRouter, delete dependency * chore(runtime): delete AngularLoader * chore(betterer): refresh results file * chore(betterer): fix out of sync results file * feat(query): fix type and import errors in QueryEditorRow * test(dashboards): delete skipped angular related tests * Tests: add back tests and fix betterer * Tests: fix broken test * Trigger build * chore(i18n): remove angular deprecation related strings * test: clean up connections and plugins catalog tests * chore(betterer): update results file --------- Co-authored-by: Hugo Häggmark <hugo.haggmark@gmail.com>
252 lines
8.3 KiB
Go
252 lines
8.3 KiB
Go
package pluginsintegration
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"gopkg.in/ini.v1"
|
|
|
|
"github.com/grafana/grafana-azure-sdk-go/v2/azsettings"
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/db"
|
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
|
"github.com/grafana/grafana/pkg/plugins"
|
|
"github.com/grafana/grafana/pkg/plugins/backendplugin/coreplugin"
|
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
|
"github.com/grafana/grafana/pkg/services/searchV2"
|
|
"github.com/grafana/grafana/pkg/services/sqlstore"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
"github.com/grafana/grafana/pkg/tests/testsuite"
|
|
"github.com/grafana/grafana/pkg/tsdb/azuremonitor"
|
|
cloudmonitoring "github.com/grafana/grafana/pkg/tsdb/cloud-monitoring"
|
|
"github.com/grafana/grafana/pkg/tsdb/cloudwatch"
|
|
"github.com/grafana/grafana/pkg/tsdb/elasticsearch"
|
|
postgres "github.com/grafana/grafana/pkg/tsdb/grafana-postgresql-datasource"
|
|
pyroscope "github.com/grafana/grafana/pkg/tsdb/grafana-pyroscope-datasource"
|
|
testdatasource "github.com/grafana/grafana/pkg/tsdb/grafana-testdata-datasource"
|
|
"github.com/grafana/grafana/pkg/tsdb/grafanads"
|
|
"github.com/grafana/grafana/pkg/tsdb/graphite"
|
|
"github.com/grafana/grafana/pkg/tsdb/influxdb"
|
|
"github.com/grafana/grafana/pkg/tsdb/jaeger"
|
|
"github.com/grafana/grafana/pkg/tsdb/loki"
|
|
"github.com/grafana/grafana/pkg/tsdb/mssql"
|
|
"github.com/grafana/grafana/pkg/tsdb/mysql"
|
|
"github.com/grafana/grafana/pkg/tsdb/opentsdb"
|
|
"github.com/grafana/grafana/pkg/tsdb/parca"
|
|
"github.com/grafana/grafana/pkg/tsdb/prometheus"
|
|
"github.com/grafana/grafana/pkg/tsdb/tempo"
|
|
"github.com/grafana/grafana/pkg/tsdb/zipkin"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
testsuite.Run(m)
|
|
}
|
|
|
|
func TestIntegrationPluginManager(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("skipping integration test")
|
|
}
|
|
staticRootPath, err := filepath.Abs("../../../public/")
|
|
require.NoError(t, err)
|
|
|
|
features := featuremgmt.WithFeatures()
|
|
cfg := &setting.Cfg{
|
|
Raw: ini.Empty(),
|
|
StaticRootPath: staticRootPath,
|
|
Azure: &azsettings.AzureSettings{},
|
|
PluginSettings: map[string]map[string]string{
|
|
"test-app": {
|
|
"path": "../../plugins/manager/testdata/test-app",
|
|
},
|
|
"test-panel": {
|
|
"not": "included",
|
|
},
|
|
},
|
|
}
|
|
|
|
tracer := tracing.InitializeTracerForTest()
|
|
|
|
hcp := httpclient.NewProvider()
|
|
am := azuremonitor.ProvideService(hcp)
|
|
cw := cloudwatch.ProvideService(hcp)
|
|
cm := cloudmonitoring.ProvideService(hcp)
|
|
es := elasticsearch.ProvideService(hcp)
|
|
grap := graphite.ProvideService(hcp, tracer)
|
|
idb := influxdb.ProvideService(hcp, features)
|
|
lk := loki.ProvideService(hcp, tracer)
|
|
otsdb := opentsdb.ProvideService(hcp)
|
|
pr := prometheus.ProvideService(hcp)
|
|
tmpo := tempo.ProvideService(hcp)
|
|
td := testdatasource.ProvideService()
|
|
pg := postgres.ProvideService(cfg)
|
|
my := mysql.ProvideService()
|
|
ms := mssql.ProvideService(cfg)
|
|
db := db.InitTestDB(t, sqlstore.InitTestDBOpt{Cfg: cfg})
|
|
sv2 := searchV2.ProvideService(cfg, db, nil, nil, tracer, features, nil, nil, nil)
|
|
graf := grafanads.ProvideService(sv2, nil, features)
|
|
pyroscope := pyroscope.ProvideService(hcp)
|
|
parca := parca.ProvideService(hcp)
|
|
zipkin := zipkin.ProvideService(hcp)
|
|
jaeger := jaeger.ProvideService(hcp)
|
|
coreRegistry := coreplugin.ProvideCoreRegistry(tracing.InitializeTracerForTest(), am, cw, cm, es, grap, idb, lk, otsdb, pr, tmpo, td, pg, my, ms, graf, pyroscope, parca, zipkin, jaeger)
|
|
|
|
testCtx := CreateIntegrationTestCtx(t, cfg, coreRegistry)
|
|
|
|
ctx := context.Background()
|
|
verifyCorePluginCatalogue(t, ctx, testCtx.PluginStore)
|
|
verifyPluginStaticRoutes(t, ctx, testCtx.PluginStore, testCtx.PluginStore)
|
|
verifyBackendProcesses(t, testCtx.PluginRegistry.Plugins(ctx))
|
|
verifyPluginQuery(t, ctx, testCtx.PluginClient)
|
|
}
|
|
|
|
func verifyPluginQuery(t *testing.T, ctx context.Context, c plugins.Client) {
|
|
now := time.Unix(1661420870, 0)
|
|
req := &backend.QueryDataRequest{
|
|
PluginContext: backend.PluginContext{
|
|
PluginID: "grafana-testdata-datasource",
|
|
},
|
|
Queries: []backend.DataQuery{
|
|
{
|
|
RefID: "A",
|
|
TimeRange: backend.TimeRange{
|
|
From: now.Add(-5 * time.Minute),
|
|
To: now,
|
|
},
|
|
JSON: json.RawMessage(`{"scenarioId":"csv_metric_values","stringInput":"1,20,90,30,5,0"}`),
|
|
},
|
|
},
|
|
}
|
|
|
|
resp, err := c.QueryData(ctx, req)
|
|
require.NoError(t, err)
|
|
payload, err := resp.MarshalJSON()
|
|
require.NoError(t, err)
|
|
require.JSONEq(t, `{"results":{"A":{"frames":[{"schema":{"refId":"A","fields":[{"name":"time","type":"time","typeInfo":{"frame":"time.Time"}},{"name":"A-series","type":"number","typeInfo":{"frame":"int64","nullable":true}}]},"data":{"values":[[1661420570000,1661420630000,1661420690000,1661420750000,1661420810000,1661420870000],[1,20,90,30,5,0]]}}],"status":200}}}`, string(payload))
|
|
}
|
|
|
|
func verifyCorePluginCatalogue(t *testing.T, ctx context.Context, ps *pluginstore.Service) {
|
|
t.Helper()
|
|
|
|
expPanels := map[string]struct{}{
|
|
"alertlist": {},
|
|
"annolist": {},
|
|
"barchart": {},
|
|
"bargauge": {},
|
|
"canvas": {},
|
|
"dashlist": {},
|
|
"debug": {},
|
|
"gauge": {},
|
|
"geomap": {},
|
|
"gettingstarted": {},
|
|
"heatmap": {},
|
|
"histogram": {},
|
|
"live": {},
|
|
"logs": {},
|
|
"logs-new": {},
|
|
"candlestick": {},
|
|
"news": {},
|
|
"nodeGraph": {},
|
|
"flamegraph": {},
|
|
"traces": {},
|
|
"piechart": {},
|
|
"stat": {},
|
|
"state-timeline": {},
|
|
"status-history": {},
|
|
"table": {},
|
|
"text": {},
|
|
"timeseries": {},
|
|
"trend": {},
|
|
"welcome": {},
|
|
"xychart": {},
|
|
"datagrid": {},
|
|
}
|
|
|
|
expDataSources := map[string]struct{}{
|
|
"cloudwatch": {},
|
|
"grafana-azure-monitor-datasource": {},
|
|
"stackdriver": {},
|
|
"elasticsearch": {},
|
|
"graphite": {},
|
|
"influxdb": {},
|
|
"loki": {},
|
|
"opentsdb": {},
|
|
"prometheus": {},
|
|
"tempo": {},
|
|
"grafana-testdata-datasource": {},
|
|
"grafana-postgresql-datasource": {},
|
|
"mysql": {},
|
|
"mssql": {},
|
|
"grafana": {},
|
|
"alertmanager": {},
|
|
"dashboard": {},
|
|
"jaeger": {},
|
|
"mixed": {},
|
|
"zipkin": {},
|
|
"grafana-pyroscope-datasource": {},
|
|
"parca": {},
|
|
}
|
|
|
|
expApps := map[string]struct{}{
|
|
"test-app": {},
|
|
}
|
|
|
|
panels := ps.Plugins(ctx, plugins.TypePanel)
|
|
require.Equal(t, len(expPanels), len(panels))
|
|
for _, p := range panels {
|
|
p, exists := ps.Plugin(ctx, p.ID)
|
|
require.NotEqual(t, pluginstore.Plugin{}, p)
|
|
require.True(t, exists)
|
|
require.Contains(t, expPanels, p.ID)
|
|
}
|
|
|
|
dataSources := ps.Plugins(ctx, plugins.TypeDataSource)
|
|
require.Equal(t, len(expDataSources), len(dataSources))
|
|
for _, ds := range dataSources {
|
|
p, exists := ps.Plugin(ctx, ds.ID)
|
|
require.NotEqual(t, pluginstore.Plugin{}, p)
|
|
require.True(t, exists)
|
|
require.Contains(t, expDataSources, ds.ID)
|
|
}
|
|
|
|
apps := ps.Plugins(ctx, plugins.TypeApp)
|
|
require.Equal(t, len(expApps), len(apps))
|
|
for _, app := range apps {
|
|
p, exists := ps.Plugin(ctx, app.ID)
|
|
require.True(t, exists)
|
|
require.NotNil(t, p)
|
|
require.Contains(t, expApps, app.ID)
|
|
}
|
|
|
|
require.Equal(t, len(expPanels)+len(expDataSources)+len(expApps), len(ps.Plugins(ctx)))
|
|
}
|
|
|
|
func verifyPluginStaticRoutes(t *testing.T, ctx context.Context, rr plugins.StaticRouteResolver, ps *pluginstore.Service) {
|
|
routes := make(map[string]*plugins.StaticRoute)
|
|
for _, route := range rr.Routes(ctx) {
|
|
routes[route.PluginID] = route
|
|
}
|
|
|
|
require.Len(t, routes, 1)
|
|
|
|
testAppPlugin, _ := ps.Plugin(ctx, "test-app")
|
|
require.Contains(t, routes, "test-app")
|
|
require.Equal(t, routes["test-app"].Directory, testAppPlugin.Base())
|
|
}
|
|
|
|
func verifyBackendProcesses(t *testing.T, ps []*plugins.Plugin) {
|
|
for _, p := range ps {
|
|
if p.Backend {
|
|
pc, exists := p.Client()
|
|
require.True(t, exists)
|
|
require.NotNil(t, pc)
|
|
}
|
|
}
|
|
}
|