github.com/verrazzano/verrazzano@v1.7.1/tests/e2e/multicluster/verify-jaeger/system/jaeger_system_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 system 5 6 import ( 7 "fmt" 8 "os" 9 "time" 10 11 . "github.com/onsi/ginkgo/v2" 12 . "github.com/onsi/gomega" 13 "github.com/verrazzano/verrazzano/tests/e2e/pkg" 14 dump "github.com/verrazzano/verrazzano/tests/e2e/pkg/test/clusterdump" 15 "github.com/verrazzano/verrazzano/tests/e2e/pkg/test/framework" 16 ) 17 18 const ( 19 shortPollingInterval = 10 * time.Second 20 shortWaitTimeout = 5 * time.Minute 21 longPollingInterval = 30 * time.Second 22 longWaitTimeout = 10 * time.Minute 23 jaegerOperatorSampleMetric = "jaeger_operator_instances_managed" 24 jaegerCollectorSampleMetric = "jaeger_collector_queue_capacity" 25 ) 26 27 var start time.Time 28 29 var t = framework.NewTestFramework("jaeger_mc_system_test") 30 31 var ( 32 adminKubeConfigPath = os.Getenv("ADMIN_KUBECONFIG") 33 clusterName = os.Getenv("CLUSTER_NAME") 34 clusterNameLabel string 35 metricsTest pkg.MetricsTest 36 failed = false 37 ) 38 39 var beforeSuite = t.BeforeSuiteFunc(func() { 40 // Allow 3hr allowance for the traces. 41 start = time.Now().Add(-3 * time.Hour) 42 if adminKubeConfigPath == "" { 43 AbortSuite("Required env variable ADMIN_KUBECONFIG not set.") 44 } 45 46 var err error 47 clusterNameLabel, err = pkg.GetClusterNameMetricLabel(adminKubeConfigPath) 48 if err != nil { 49 AbortSuite(fmt.Sprintf("Failed to get cluster label for metric collection: %v", err)) 50 } 51 52 m := make(map[string]string) 53 m[clusterNameLabel] = getClusterName() 54 metricsTest, err = pkg.NewMetricsTest(adminKubeConfigPath, m) 55 if err != nil { 56 AbortSuite(fmt.Sprintf("Failed to create the Metrics test object: %v", err)) 57 } 58 59 }) 60 61 var _ = BeforeSuite(beforeSuite) 62 63 var _ = t.AfterEach(func() { 64 failed = failed || CurrentSpecReport().Failed() 65 }) 66 67 var afterSuite = t.AfterSuiteFunc(func() { 68 if failed { 69 err := dump.ExecuteBugReport() 70 if err != nil { 71 pkg.Log(pkg.Error, err.Error()) 72 } 73 } 74 }) 75 76 var _ = AfterSuite(afterSuite) 77 78 var _ = t.Describe("Multi Cluster Jaeger Validation", Label("f:platform-lcm.install"), func() { 79 80 // GIVEN a multicluster setup with an admin and a manged cluster, 81 // WHEN Jaeger operator is enabled in the admin cluster and the managed cluster is registered to it, 82 // THEN system traces can be queried from the Jaeger UI in the admin cluster 83 t.It("traces from verrazzano system components of managed cluster should be available when queried from Jaeger", func() { 84 validatorFn := pkg.ValidateSystemTracesFuncInCluster(adminKubeConfigPath, start, getClusterName()) 85 Eventually(validatorFn).WithPolling(longPollingInterval).WithTimeout(longWaitTimeout).Should(BeTrue()) 86 }) 87 88 // GIVEN a multicluster setup with an admin and a manged cluster, 89 // WHEN Jaeger operator is enabled in the admin cluster and the managed cluster is registered to it, 90 // THEN we are able to query the metrics of Jaeger operator running in managed cluster 91 // from the prometheus service running admin cluster. 92 t.It("metrics of jaeger operator running in managed cluster are available in prometheus of admin cluster", func() { 93 Eventually(func() bool { 94 return metricsTest.MetricsExist(jaegerOperatorSampleMetric, map[string]string{}) 95 }).WithPolling(shortPollingInterval).WithTimeout(shortWaitTimeout).Should(BeTrue()) 96 }) 97 98 // GIVEN a multicluster setup with an admin and a manged cluster, 99 // WHEN Jaeger operator is enabled in the admin cluster and the managed cluster is registered to it, 100 // THEN we are able to query the metrics of Jaeger collector running in managed cluster 101 // from the prometheus service running admin cluster. 102 t.It("metrics of jaeger collector running in managed cluster are available in prometheus of admin cluster", func() { 103 Eventually(func() bool { 104 return metricsTest.MetricsExist(jaegerCollectorSampleMetric, map[string]string{}) 105 }).WithPolling(shortPollingInterval).WithTimeout(shortWaitTimeout).Should(BeTrue()) 106 }) 107 }) 108 109 func getClusterName() string { 110 if clusterName == "admin" { 111 return "local" 112 } 113 return clusterName 114 }