You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by zh...@apache.org on 2022/04/07 01:25:44 UTC

[apisix-ingress-controller] branch master updated: feat(e2e): add e2e test for prometheus (#942)

This is an automated email from the ASF dual-hosted git repository.

zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git


The following commit(s) were added to refs/heads/master by this push:
     new de33d05a feat(e2e): add e2e test for prometheus (#942)
de33d05a is described below

commit de33d05aeff9ec5fdd1a2431c01535566437ee12
Author: John Chever <ch...@gmail.com>
AuthorDate: Thu Apr 7 09:25:39 2022 +0800

    feat(e2e): add e2e test for prometheus (#942)
---
 Makefile                         |  4 ++--
 test/e2e/features/global_rule.go | 29 ++++++++++++++++++++++++++++-
 test/e2e/plugins/server-info.go  |  1 +
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 10dacf71..dc00715b 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/test/e2e/features/global_rule.go b/test/e2e/features/global_rule.go
index 21bb78ee..aade03d8 100644
--- a/test/e2e/features/global_rule.go
+++ b/test/e2e/features/global_rule.go
@@ -15,6 +15,8 @@
 package features
 
 import (
+	"fmt"
+	"net/http"
 	"time"
 
 	"github.com/apache/apisix-ingress-controller/pkg/id"
@@ -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
@@ -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)
@@ -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")
diff --git a/test/e2e/plugins/server-info.go b/test/e2e/plugins/server-info.go
index 8b50e50e..218f03b3 100644
--- a/test/e2e/plugins/server-info.go
+++ b/test/e2e/plugins/server-info.go
@@ -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)