Skip to content

Commit

Permalink
TestData: Introduce schema types (grafana#62130)
Browse files Browse the repository at this point in the history
* schematize data query

* add the stuff you dingus

* feat(testdatasource): add scenario to generated types

* use generated testdata query in frontend

* update code owners

* Add path exception for testdata datasource

* use specific numeric data types

* fix test

* fix e2e smoketest

* add test data query type

* use test data query type

* fix betterer

* Fix typo

* move to experimental

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: sam boyer <sdboyer@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
  • Loading branch information
5 people authored Jan 26, 2023
1 parent 0cd1409 commit 4273253
Show file tree
Hide file tree
Showing 30 changed files with 876 additions and 225 deletions.
17 changes: 4 additions & 13 deletions .betterer.results
Original file line number Diff line number Diff line change
Expand Up @@ -6710,12 +6710,9 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Do not use any type assertions.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"]
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
],
"public/app/plugins/datasource/testdata/components/PredictablePulseEditor.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
Expand Down Expand Up @@ -6750,10 +6747,7 @@ exports[`better eslint`] = {
"public/app/plugins/datasource/testdata/datasource.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"public/app/plugins/datasource/testdata/module.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
Expand All @@ -6773,9 +6767,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/plugins/datasource/testdata/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/zipkin/QueryField.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
Expand Down
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ WORKFLOW.md @torkelo
/pkg/services/querylibrary/ @grafana/multitenancy-squad
/pkg/services/export/ @grafana/multitenancy-squad
/pkg/infra/filestorage/ @grafana/multitenancy-squad
/pkg/tsdb/testdatasource/ @grafana/multitenancy-squad
/pkg/util/converter/ @grafana/multitenancy-squad

# Alerting
Expand All @@ -281,6 +280,7 @@ WORKFLOW.md @torkelo
/pkg/services/datasources/ @grafana/plugins-platform-backend
/pkg/services/pluginsintegration/ @grafana/plugins-platform-backend
/pkg/plugins/pfs/ @grafana/plugins-platform-backend @grafana/grafana-as-code
/pkg/tsdb/testdatasource/ @grafana/plugins-platform-backend

# Dashboard previews / crawler (behind feature flag)
/pkg/services/thumbs/ @grafana/multitenancy-squad
Expand Down Expand Up @@ -486,7 +486,7 @@ lerna.json @grafana/frontend-ops
/public/app/plugins/datasource/cloudwatch/ @grafana/aws-plugins
/public/app/plugins/datasource/elasticsearch/ @grafana/observability-logs
/public/app/plugins/datasource/grafana/ @grafana/user-essentials
/public/app/plugins/datasource/testdata/ @grafana/backend-platform
/public/app/plugins/datasource/testdata/ @grafana/plugins-platform-frontend
/public/app/plugins/datasource/grafana-azure-monitor-datasource/ @grafana/partner-plugins
/public/app/plugins/datasource/graphite/ @grafana/observability-metrics
/public/app/plugins/datasource/influxdb/ @grafana/observability-metrics
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/grafana-e2e/src/flows/addDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const addDataSource = (config?: Partial<AddDataSourceConfig>) => {
form: () => {},
name: `e2e-${uuidv4()}`,
skipTlsVerify: false,
type: 'TestData DB',
type: 'TestData',
...config,
};

Expand Down
46 changes: 24 additions & 22 deletions pkg/kindsys/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -1539,29 +1539,31 @@
"pluralName": "TempoDataSourceCfgs",
"schemaInterface": "DataSourceCfg"
},
"testdatadbdataquery": {
"testdatadataquery": {
"category": "composable",
"codeowners": [],
"codeowners": [
"grafana/plugins-platform-frontend"
],
"currentVersion": [
0,
0
],
"grafanaMaturityCount": 0,
"lineageIsGroup": false,
"links": {
"docs": "n/a",
"go": "n/a",
"schema": "n/a",
"ts": "n/a"
"docs": "https://grafana.com/docs/grafana/next/developers/kinds/composable/testdatadataquery/schema-reference",
"go": "https://github.com/grafana/grafana/tree/main/pkg/tsdb/testdata/kinds/dataquery/types_dataquery_gen.go",
"schema": "https://github.com/grafana/grafana/tree/main/public/app/plugins/datasource/testdata/dataquery.cue",
"ts": "https://github.com/grafana/grafana/tree/main/public/app/plugins/datasource/testdata/dataquery.gen.ts"
},
"machineName": "testdatadbdataquery",
"maturity": "planned",
"name": "TestDataDBDataQuery",
"pluralMachineName": "testdatadbdataquerys",
"pluralName": "TestDataDBDataQuerys",
"machineName": "testdatadataquery",
"maturity": "experimental",
"name": "TestDataDataQuery",
"pluralMachineName": "testdatadataquerys",
"pluralName": "TestDataDataQuerys",
"schemaInterface": "DataQuery"
},
"testdatadbdatasourcecfg": {
"testdatadatasourcecfg": {
"category": "composable",
"codeowners": [],
"currentVersion": [
Expand All @@ -1576,11 +1578,11 @@
"schema": "n/a",
"ts": "n/a"
},
"machineName": "testdatadbdatasourcecfg",
"machineName": "testdatadatasourcecfg",
"maturity": "planned",
"name": "TestDataDBDataSourceCfg",
"pluralMachineName": "testdatadbdatasourcecfgs",
"pluralName": "TestDataDBDataSourceCfgs",
"name": "TestDataDataSourceCfg",
"pluralMachineName": "testdatadatasourcecfgs",
"pluralName": "TestDataDataSourceCfgs",
"schemaInterface": "DataSourceCfg"
},
"textpanelcfg": {
Expand Down Expand Up @@ -1824,8 +1826,8 @@
"tableoldpanelcfg",
"tempodataquery",
"tempodatasourcecfg",
"testdatadbdataquery",
"testdatadbdatasourcecfg",
"testdatadataquery",
"testdatadatasourcecfg",
"textpanelcfg",
"tracespanelcfg",
"welcomepanelcfg",
Expand Down Expand Up @@ -1871,10 +1873,11 @@
"statetimelinepanelcfg",
"statpanelcfg",
"statushistorypanelcfg",
"testdatadataquery",
"textpanelcfg",
"xychartpanelcfg"
],
"count": 14
"count": 15
},
"mature": {
"name": "mature",
Expand Down Expand Up @@ -1946,16 +1949,15 @@
"tableoldpanelcfg",
"tempodataquery",
"tempodatasourcecfg",
"testdatadbdataquery",
"testdatadbdatasourcecfg",
"testdatadatasourcecfg",
"thumb",
"tracespanelcfg",
"user",
"welcomepanelcfg",
"zipkindataquery",
"zipkindatasourcecfg"
],
"count": 58
"count": 57
},
"stable": {
"name": "stable",
Expand Down
5 changes: 5 additions & 0 deletions pkg/plugins/codegen/jenny_plugingotypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ func (j *pgoJenny) Generate(decl *pfs.PluginDecl) (*codejen.File, error) {
}

pluginfolder := filepath.Base(decl.PluginPath)
// hardcoded exception for testdata datasource, ONLY because "testdata" is basically a
// language-reserved keyword for Go
if pluginfolder == "testdata" {
pluginfolder = "testdatasource"
}
filename := fmt.Sprintf("types_%s_gen.go", slotname)
return codejen.NewFile(filepath.Join(j.root, pluginfolder, "kinds", slotname, filename), byt, j), nil
}
2 changes: 1 addition & 1 deletion pkg/tests/api/plugins/data/expectedListResp.json
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@
"signatureOrg": ""
},
{
"name": "TestData DB",
"name": "TestData",
"type": "datasource",
"id": "testdata",
"enabled": true,
Expand Down
Loading

0 comments on commit 4273253

Please sign in to comment.