@@ -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,28 +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_duration_seconds_total` ,
355- `mantle_mantlebackupconfig_info` ,
356- `mantle_backup_duration_seconds_buckets` ,
357- `mantle_backup_duration_seconds_sum` ,
358- `mantle_backup_duration_seconds_count` ,
359- }
360- ensureMetricsAreExposed (metrics )
361- })
362384})
363-
364- func ensureMetricsAreExposed (metrics []string ) {
365- GinkgoHelper ()
366- controllerPod , err := GetControllerPodName (PrimaryK8sCluster )
367- Expect (err ).NotTo (HaveOccurred ())
368-
369- stdout , _ , err := Kubectl (PrimaryK8sCluster , nil , "exec" , "-n" , CephClusterNamespace , controllerPod , "--" ,
370- "curl" , "-s" , "http://localhost:8080/metrics" )
371- Expect (err ).NotTo (HaveOccurred ())
372- for _ , metric := range metrics {
373- Expect (strings .Contains (string (stdout ), metric )).To (BeTrue ())
374- }
375- }
0 commit comments