-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Test grafana dashboards in hubble deploy (#650)
# Description Closes #501 ## Related Issue The refactored hubble deployment included in grafana dashboard testing. Also renamed the dashboards folder to match the `grafana` application and the Makefile setup. This make phony is not run in CI and tests are run via `make test` so this folder issue does not show up. ## Checklist - [x] I have read the [contributing documentation](https://retina.sh/docs/contributing). - [x] I signed and signed-off the commits (`git commit -S -s ...`). See [this documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification) on signing commits. - [x] I have correctly attributed the author(s) of the code. - [x] I have tested the changes locally. - [x] I have followed the project's style guidelines. - [x] I have updated the documentation, if necessary. - [x] I have added tests, if applicable. ## Screenshots (if applicable) or Testing Completed ```bash go test ./... -tags=dashboard -v === RUN TestDashboardsAreSimplified simplify-grafana_test.go:21: verifying that dashboard is simplified: ../../../hubble/grafana/dashboards/clusters.json simplify-grafana_test.go:21: verifying that dashboard is simplified: ../../../hubble/grafana/dashboards/dns.json simplify-grafana_test.go:21: verifying that dashboard is simplified: ../../../hubble/grafana/dashboards/pod-flows-namespace.json simplify-grafana_test.go:21: verifying that dashboard is simplified: ../../../hubble/grafana/dashboards/pod-flows-workload.json simplify-grafana_test.go:21: verifying that dashboard is simplified: ../../../legacy/grafana/dashboards/clusters.json simplify-grafana_test.go:21: verifying that dashboard is simplified: ../../../legacy/grafana/dashboards/dns.json simplify-grafana_test.go:21: verifying that dashboard is simplified: ../../../legacy/grafana/dashboards/pod-level.json --- PASS: TestDashboardsAreSimplified (0.01s) PASS ok github.com/microsoft/retina/deploy/testutils/grafana/dashboards (cached) ``` ```bash make simplify-dashboards cd deploy/testutils && go test ./... -tags=dashboard,simplifydashboard -v && cd /home/tisham/dev/retina === RUN TestOverwriteDashboards simplify-grafana-overwrite_test.go:20: simplifying/overwriting dashboard: ../../../hubble/grafana/dashboards/clusters.json simplify-grafana-overwrite_test.go:20: simplifying/overwriting dashboard: ../../../hubble/grafana/dashboards/dns.json simplify-grafana-overwrite_test.go:20: simplifying/overwriting dashboard: ../../../hubble/grafana/dashboards/pod-flows-namespace.json simplify-grafana-overwrite_test.go:20: simplifying/overwriting dashboard: ../../../hubble/grafana/dashboards/pod-flows-workload.json simplify-grafana-overwrite_test.go:20: simplifying/overwriting dashboard: ../../../legacy/grafana/dashboards/clusters.json simplify-grafana-overwrite_test.go:20: simplifying/overwriting dashboard: ../../../legacy/grafana/dashboards/dns.json simplify-grafana-overwrite_test.go:20: simplifying/overwriting dashboard: ../../../legacy/grafana/dashboards/pod-level.json --- PASS: TestOverwriteDashboards (0.01s) PASS ok github.com/microsoft/retina/deploy/testutils/grafana/dashboards 0.013s ``` ## Additional Notes This PR duplicates code if more dashboard folders are added it would perhaps be useful to improve the go test code to receive a list of folders instead. --- Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more information on how to contribute to this project.
- Loading branch information
Showing
12 changed files
with
64 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 0 additions & 33 deletions
33
deploy/legacy/graphana/dashboards/simplify-grafana_test.go
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
deploy/testutils/grafana/dashboards/simplify-grafana_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//go:build dashboard && !simplifydashboard | ||
|
||
package dashboard | ||
|
||
import ( | ||
"path/filepath" | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
// TestDashboardsAreSimplified ensures that all dashboards are simplified | ||
func TestDashboardsAreSimplified(t *testing.T) { | ||
// get all json's in this folder | ||
files, err := filepath.Glob("../../../*/grafana/dashboards/*.json") | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
for _, file := range files { | ||
t.Logf("verifying that dashboard is simplified: %s", file) | ||
|
||
sourcePath := file | ||
simplified := SimplifyGrafana(sourcePath, false) | ||
original := ParseDashboard(sourcePath) | ||
|
||
if !reflect.DeepEqual(simplified, original) { | ||
t.Errorf("ERROR: dashboard has not been simplified. Please run: make simplify-dashboards") | ||
} | ||
} | ||
} |