github.com/verrazzano/verrazzano@v1.7.1/tests/e2e/upgrade/post-upgrade/grafana/grafana_test.go (about) 1 // Copyright (c) 2022, 2023, Oracle and/or its affiliates. 2 // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 4 package grafana 5 6 import ( 7 "fmt" 8 "time" 9 10 . "github.com/onsi/ginkgo/v2" 11 . "github.com/onsi/gomega" 12 "github.com/verrazzano/verrazzano/pkg/k8sutil" 13 "github.com/verrazzano/verrazzano/tests/e2e/pkg" 14 "github.com/verrazzano/verrazzano/tests/e2e/pkg/test/framework" 15 ) 16 17 const ( 18 waitTimeout = 3 * time.Minute 19 pollingInterval = 10 * time.Second 20 ) 21 22 var t = framework.NewTestFramework("grafana") 23 24 var beforeSuite = t.BeforeSuiteFunc(func() { 25 kubeconfigPath, err := k8sutil.GetKubeConfigLocation() 26 if err != nil { 27 Fail(fmt.Sprintf(pkg.KubeConfigErrorFmt, err)) 28 } 29 supported := pkg.IsGrafanaEnabled(kubeconfigPath) 30 // Only run tests if Grafana component is enabled in Verrazzano CR 31 if !supported { 32 Skip("Grafana component is not enabled") 33 } 34 }) 35 36 var _ = BeforeSuite(beforeSuite) 37 38 var _ = t.Describe("Post Upgrade Grafana Dashboard", Label("f:observability.logging.es"), func() { 39 40 // GIVEN a running Grafana instance, 41 // WHEN a search is made for the dashboard using its title, 42 // THEN the dashboard metadata is returned. 43 t.It("Search the test Grafana Dashboard using its title", func() { 44 pkg.TestSearchGrafanaDashboard(pollingInterval, waitTimeout) 45 }) 46 47 // GIVEN a running grafana instance, 48 // WHEN a GET call is made to Grafana with the UID of the system dashboard, 49 // THEN the dashboard metadata of the corresponding System dashboard is returned. 50 t.It("Get details of the system Grafana dashboard", func() { 51 kubeConfigPath, err := k8sutil.GetKubeConfigLocation() 52 Expect(err).To(BeNil(), fmt.Sprintf(pkg.KubeConfigErrorFmt, err)) 53 systemHealthDashboardExists, err := pkg.IsVerrazzanoMinVersion("1.5.0", kubeConfigPath) 54 Expect(err).To(BeNil(), fmt.Sprintf("could not find verrazzzano min version: %v", err)) 55 if systemHealthDashboardExists { 56 pkg.TestSystemHealthGrafanaDashboard(pollingInterval, waitTimeout) 57 } 58 pkg.TestSystemHealthGrafanaDashboard(pollingInterval, waitTimeout) 59 }) 60 61 kubeconfigPath, err := k8sutil.GetKubeConfigLocation() 62 if err != nil { 63 Expect(err).To(BeNil(), fmt.Sprintf(pkg.KubeConfigErrorFmt, err)) 64 } 65 66 // GIVEN a running grafana instance 67 // WHEN a call is made to Grafana Dashboard with UID corresponding to OpenSearch Summary Dashboard 68 // THEN the dashboard metadata of the corresponding dashboard is returned 69 if ok, _ := pkg.IsVerrazzanoMinVersion("1.3.0", kubeconfigPath); ok { 70 t.It("Get details of the OpenSearch Grafana Dashboard", func() { 71 pkg.TestOpenSearchGrafanaDashBoard(pollingInterval, waitTimeout) 72 }) 73 } 74 })