15
15
package features
16
16
17
17
import (
18
+ "fmt"
19
+ "net/http"
18
20
"time"
19
21
20
22
"github.com/apache/apisix-ingress-controller/pkg/id"
@@ -35,6 +37,7 @@ var _ = ginkgo.Describe("ApisixClusterConfig", func() {
35
37
}
36
38
s := scaffold .NewScaffold (opts )
37
39
ginkgo .It ("enable prometheus" , func () {
40
+ adminSvc , adminPort := s .ApisixAdminServiceAndPort ()
38
41
acc := `
39
42
apiVersion: apisix.apache.org/v2beta3
40
43
kind: ApisixClusterConfig
56
59
// Wait until the ApisixClusterConfig create event was delivered.
57
60
time .Sleep (3 * time .Second )
58
61
62
+ ar := fmt .Sprintf (`
63
+ apiVersion: apisix.apache.org/v2beta3
64
+ kind: ApisixRoute
65
+ metadata:
66
+ name: default
67
+ spec:
68
+ http:
69
+ - name: public-api
70
+ match:
71
+ paths:
72
+ - /apisix/prometheus/metrics
73
+ backends:
74
+ - serviceName: %s
75
+ servicePort: %d
76
+ plugins:
77
+ - name: public-api
78
+ enable: true
79
+ ` , adminSvc , adminPort )
80
+
81
+ err = s .CreateResourceFromString (ar )
82
+ assert .Nil (ginkgo .GinkgoT (), err , "creating ApisixRouteConfig" )
83
+
84
+ time .Sleep (3 * time .Second )
85
+
59
86
grs , err := s .ListApisixGlobalRules ()
60
87
assert .Nil (ginkgo .GinkgoT (), err , "listing global_rules" )
61
88
assert .Len (ginkgo .GinkgoT (), grs , 1 )
65
92
assert .Equal (ginkgo .GinkgoT (), ok , true )
66
93
67
94
resp := s .NewAPISIXClient ().GET ("/apisix/prometheus/metrics" ).Expect ()
68
- resp .Status (200 )
95
+ resp .Status (http . StatusOK )
69
96
resp .Body ().Contains ("# HELP apisix_etcd_modify_indexes Etcd modify index for APISIX keys" )
70
97
resp .Body ().Contains ("# HELP apisix_etcd_reachable Config server etcd reachable from APISIX, 0 is unreachable" )
71
98
resp .Body ().Contains ("# HELP apisix_node_info Info of APISIX node" )
0 commit comments