@@ -14,6 +14,39 @@ import (
1414 "k8s.io/apimachinery/pkg/api/meta"
1515)
1616
17+ var _ = Describe ("metrics tests" , func () {
18+ namespace := util .GetUniqueName ("ns-" )
19+ pvcName := util .GetUniqueName ("pvc-" )
20+ backupName := util .GetUniqueName ("mb-" )
21+ backupConfigName := util .GetUniqueName ("mbc-" )
22+
23+ It ("should setup" , func (ctx SpecContext ) {
24+ SetupEnvironment (namespace )
25+ CreatePVC (ctx , PrimaryK8sCluster , namespace , pvcName )
26+ CreateMantleBackup (PrimaryK8sCluster , namespace , pvcName , backupName )
27+ WaitMantleBackupSynced (namespace , backupName )
28+ CreateMantleBackupConfig (PrimaryK8sCluster , namespace , pvcName , backupConfigName )
29+ })
30+
31+ DescribeTable ("metrics should be exposed" ,
32+ func (ctx SpecContext , metricName string ) {
33+ Eventually (ctx , func (g Gomega ) {
34+ controllerPod , err := GetControllerPodName (PrimaryK8sCluster )
35+ g .Expect (err ).NotTo (HaveOccurred ())
36+ stdout , _ , err := Kubectl (PrimaryK8sCluster , nil , "exec" , "-n" , CephClusterNamespace , controllerPod , "--" ,
37+ "curl" , "-s" , "http://localhost:8080/metrics" )
38+ g .Expect (err ).NotTo (HaveOccurred ())
39+ g .Expect (strings .Contains (string (stdout ), metricName )).To (BeTrue ())
40+ }).Should (Succeed ())
41+ },
42+ Entry (`mantle_backup_duration_seconds_total` , `mantle_backup_duration_seconds_total` ),
43+ Entry (`mantle_mantlebackupconfig_info` , `mantle_mantlebackupconfig_info` ),
44+ Entry (`mantle_backup_duration_seconds_bucket` , `mantle_backup_duration_seconds_bucket` ),
45+ Entry (`mantle_backup_duration_seconds_sum` , `mantle_backup_duration_seconds_sum` ),
46+ Entry (`mantle_backup_duration_seconds_count` , `mantle_backup_duration_seconds_count` ),
47+ )
48+ })
49+
1750var _ = Describe ("miscellaneous tests" , func () {
1851 It ("should succeed to back up if backup-transfer-part-size is changed during uploading" , func (ctx SpecContext ) {
1952 namespace := util .GetUniqueName ("ns-" )
@@ -348,25 +381,4 @@ spec:
348381 0 , // reset an import Job to the original one to revive the Job.
349382 ),
350383 )
351-
352- It ("should get metrics from the controller pod in the primary cluster" , func (ctx SpecContext ) {
353- metrics := []string {
354- `mantle_backup_creation_duration_seconds_count` ,
355- `mantle_backup_creation_duration_seconds_sum` ,
356- }
357- ensureMetricsAreExposed (metrics )
358- })
359384})
360-
361- func ensureMetricsAreExposed (metrics []string ) {
362- GinkgoHelper ()
363- controllerPod , err := GetControllerPodName (PrimaryK8sCluster )
364- Expect (err ).NotTo (HaveOccurred ())
365-
366- stdout , _ , err := Kubectl (PrimaryK8sCluster , nil , "exec" , "-n" , CephClusterNamespace , controllerPod , "--" ,
367- "curl" , "-s" , "http://localhost:8080/metrics" )
368- Expect (err ).NotTo (HaveOccurred ())
369- for _ , metric := range metrics {
370- Expect (strings .Contains (string (stdout ), metric )).To (BeTrue ())
371- }
372- }
0 commit comments