Skip to content

Commit

Permalink
feat(e2e): add e2e test for prometheus (#942)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chever-John committed Apr 7, 2022
1 parent 7e4ec36 commit de33d05
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -87,8 +87,8 @@ endif
.PHONY: push-images
push-images:
ifeq ($(E2E_SKIP_BUILD), 0)
docker pull apache/apisix:2.12.0-alpine
docker tag apache/apisix:2.12.0-alpine $(REGISTRY)/apache/apisix:dev
docker pull apache/apisix:2.13.0-alpine
docker tag apache/apisix:2.13.0-alpine $(REGISTRY)/apache/apisix:dev
docker push $(REGISTRY)/apache/apisix:dev

docker pull bitnami/etcd:3.4.14-debian-10-r0
Expand Down
29 changes: 28 additions & 1 deletion test/e2e/features/global_rule.go
Expand Up @@ -15,6 +15,8 @@
package features

import (
"fmt"
"net/http"
"time"

"github.com/apache/apisix-ingress-controller/pkg/id"
Expand All @@ -35,6 +37,7 @@ var _ = ginkgo.Describe("ApisixClusterConfig", func() {
}
s := scaffold.NewScaffold(opts)
ginkgo.It("enable prometheus", func() {
adminSvc, adminPort := s.ApisixAdminServiceAndPort()
acc := `
apiVersion: apisix.apache.org/v2beta3
kind: ApisixClusterConfig
Expand All @@ -56,6 +59,30 @@ spec:
// Wait until the ApisixClusterConfig create event was delivered.
time.Sleep(3 * time.Second)

ar := fmt.Sprintf(`
apiVersion: apisix.apache.org/v2beta3
kind: ApisixRoute
metadata:
name: default
spec:
http:
- name: public-api
match:
paths:
- /apisix/prometheus/metrics
backends:
- serviceName: %s
servicePort: %d
plugins:
- name: public-api
enable: true
`, adminSvc, adminPort)

err = s.CreateResourceFromString(ar)
assert.Nil(ginkgo.GinkgoT(), err, "creating ApisixRouteConfig")

time.Sleep(3 * time.Second)

grs, err := s.ListApisixGlobalRules()
assert.Nil(ginkgo.GinkgoT(), err, "listing global_rules")
assert.Len(ginkgo.GinkgoT(), grs, 1)
Expand All @@ -65,7 +92,7 @@ spec:
assert.Equal(ginkgo.GinkgoT(), ok, true)

resp := s.NewAPISIXClient().GET("/apisix/prometheus/metrics").Expect()
resp.Status(200)
resp.Status(http.StatusOK)
resp.Body().Contains("# HELP apisix_etcd_modify_indexes Etcd modify index for APISIX keys")
resp.Body().Contains("# HELP apisix_etcd_reachable Config server etcd reachable from APISIX, 0 is unreachable")
resp.Body().Contains("# HELP apisix_node_info Info of APISIX node")
Expand Down
1 change: 1 addition & 0 deletions test/e2e/plugins/server-info.go
Expand Up @@ -33,6 +33,7 @@ var _ = ginkgo.Describe("server-info plugin", func() {
s := scaffold.NewScaffold(opts)

ginkgo.It("enable server-info plugin", func() {
ginkgo.Skip("This plugin is disabled by default in APISIX v2.13.")
serverInfoKey := [...]string{"etcd_version", "up_time", "last_report_time", "id", "hostname", "version", "boot_time"}
serverInfo, err := s.GetServerInfo()
assert.Nil(ginkgo.GinkgoT(), err)
Expand Down

0 comments on commit de33d05

Please sign in to comment.