Schema: get all devenv dashboards passing validation (#37857)
* Strip nulls (again) * Add stripnulls script * Add transformations field * Close FieldConfig struct; proper plugin validating * s/graph/viz/ field in histogram dashboard * Use ui.GraphFieldConfig in histogram model * Add models for stat, gauge, barguage panel plugins Also toss necessary shared types into cue/ui/gen.cue, with TODOs to move them appropriately later. * Add required license headers * Heap of updates to cue UI components * Fix barchart types and one old devenv input * Use the GraphFieldConfig directly for timeseries * Add models.cue for a few panel plugins Barchart, state-timeline, and status-history * Enable the test validating all devenv dashboards!! * Fix effects of not checking after making comments * Update packages/grafana-ui/src/options/models.gen.ts Co-authored-by: Ryan McKinley <ryantxu@gmail.com> * Realign and unalign cue with ts types * Update devenv test to sniff for null errors Best option we have right now for helping people to know they need to strip nulls from devenv dashboards. * Add speculative default for barchart stacking * Fixup some dated devenv dashboards timeline-modes needed to be regenerated with the appropriate tooltip values included, per typing requirements, and timeline-demo needed to have the `mode` field removed, as it is not intended to be persisted. * Add necessary missing options for various panels * Regenerate devenv dashboards Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
co-authored by
Ryan McKinley
parent
368da73ac4
commit
6aba592741
@@ -7,6 +7,7 @@ import (
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"testing/fstest"
|
||||
|
||||
@@ -49,17 +50,8 @@ func TestScuemataBasics(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDevenvDashboardValidity(t *testing.T) {
|
||||
// TODO un-skip when tests pass on all devenv dashboards
|
||||
t.Skip()
|
||||
// validdir := os.DirFS(filepath.Join("..", "..", "..", "devenv", "dev-dashboards"))
|
||||
validdir := filepath.Join("..", "..", "..", "devenv", "dev-dashboards")
|
||||
|
||||
dash, err := BaseDashboardFamily(p)
|
||||
require.NoError(t, err, "error while loading base dashboard scuemata")
|
||||
|
||||
ddash, err := DistDashboardFamily(p)
|
||||
require.NoError(t, err, "error while loading dist dashboard scuemata")
|
||||
|
||||
doTest := func(sch schema.VersionedCueSchema) func(t *testing.T) {
|
||||
return func(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -87,7 +79,9 @@ func TestDevenvDashboardValidity(t *testing.T) {
|
||||
return nil
|
||||
} else {
|
||||
if !(oldschemav.(float64) > 29) {
|
||||
t.Logf("schemaVersion is %v, older than 30, skipping %s", oldschemav, path)
|
||||
if testing.Verbose() {
|
||||
t.Logf("schemaVersion is %v, older than 30, skipping %s", oldschemav, path)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -96,7 +90,12 @@ func TestDevenvDashboardValidity(t *testing.T) {
|
||||
err := sch.Validate(schema.Resource{Value: byt, Name: path})
|
||||
if err != nil {
|
||||
// Testify trims errors to short length. We want the full text
|
||||
t.Fatal(errors.Details(err, nil))
|
||||
errstr := errors.Details(err, nil)
|
||||
t.Log(errstr)
|
||||
if strings.Contains(errstr, "null") {
|
||||
t.Log("validation failure appears to involve nulls - see if scripts/stripnulls.sh has any effect?")
|
||||
}
|
||||
t.FailNow()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -107,7 +106,15 @@ func TestDevenvDashboardValidity(t *testing.T) {
|
||||
|
||||
// TODO will need to expand this appropriately when the scuemata contain
|
||||
// more than one schema
|
||||
t.Run("base", doTest(dash))
|
||||
|
||||
// TODO disabled because base variant validation currently must fail in order for
|
||||
// dist/instance validation to do closed validation of plugin-specified fields
|
||||
// t.Run("base", doTest(dash))
|
||||
// dash, err := BaseDashboardFamily(p)
|
||||
// require.NoError(t, err, "error while loading base dashboard scuemata")
|
||||
|
||||
ddash, err := DistDashboardFamily(p)
|
||||
require.NoError(t, err, "error while loading dist dashboard scuemata")
|
||||
t.Run("dist", doTest(ddash))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user