This is an automated email from the ASF dual-hosted git repository. ronething pushed a commit to branch feat/ingressannotaions in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git
commit b7504b1d168246355f4da2522c32c253520092cc Author: Ashing Zheng <[email protected]> AuthorDate: Mon Jan 12 13:21:34 2026 +0800 fix: r Signed-off-by: Ashing Zheng <[email protected]> --- test/e2e/crds/v2/basic.go | 91 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 2 deletions(-) diff --git a/test/e2e/crds/v2/basic.go b/test/e2e/crds/v2/basic.go index 36205d5c..65415340 100644 --- a/test/e2e/crds/v2/basic.go +++ b/test/e2e/crds/v2/basic.go @@ -18,16 +18,26 @@ package v2 import ( + "fmt" + "net/http" + "time" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "k8s.io/apimachinery/pkg/types" + apiv2 "github.com/apache/apisix-ingress-controller/api/v2" + "github.com/apache/apisix-ingress-controller/test/e2e/framework" "github.com/apache/apisix-ingress-controller/test/e2e/scaffold" ) var _ = Describe("APISIX Standalone Basic Tests", Label("apisix.apache.org", "v2", "basic"), func() { - s := scaffold.NewDefaultScaffold() + var ( + s = scaffold.NewDefaultScaffold() + applier = framework.NewApplier(s.GinkgoT, s.K8sClient, s.CreateResourceFromString) + ) - Describe("APISIX HTTP Proxy", func() { + Context("APISIX HTTP Proxy", func() { It("should handle basic HTTP requests", func() { httpClient := s.NewAPISIXClient() Expect(httpClient).NotTo(BeNil()) @@ -52,4 +62,81 @@ var _ = Describe("APISIX Standalone Basic Tests", Label("apisix.apache.org", "v2 }) }) + + Context("IngressClass Annotations", func() { + It("Basic tests", func() { + const ingressClassYaml = ` +apiVersion: networking.k8s.io/v1 +kind: IngressClass +metadata: + name: %s + annotations: + apisix.apache.org/parameters-namespace: %s +spec: + controller: %s + parameters: + apiGroup: apisix.apache.org + kind: GatewayProxy + name: apisix-proxy-config +` + + By("create GatewayProxy") + + err := s.CreateResourceFromString(s.GetGatewayProxySpec()) + Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy") + time.Sleep(5 * time.Second) + + By("create IngressClass") + ingressClass := fmt.Sprintf(ingressClassYaml, s.Namespace(), s.Namespace(), s.GetControllerName()) + err = s.CreateResourceFromString(ingressClass) + Expect(err).NotTo(HaveOccurred(), "creating IngressClass") + time.Sleep(5 * time.Second) + + const apisixRouteSpec = ` +apiVersion: apisix.apache.org/v2 +kind: ApisixRoute +metadata: + name: default +spec: + ingressClassName: %s + http: + - name: rule0 + match: + hosts: + - httpbin + paths: + - %s + backends: + - serviceName: httpbin-service-e2e-test + servicePort: 80 +` + request := func(path string) int { + return s.NewAPISIXClient().GET(path).WithHost("httpbin").Expect().Raw().StatusCode + } + + By("apply ApisixRoute") + var apisixRoute apiv2.ApisixRoute + applier.MustApplyAPIv2(types.NamespacedName{Namespace: s.Namespace(), Name: "default"}, &apisixRoute, + fmt.Sprintf(apisixRouteSpec, s.Namespace(), "/get")) + + By("verify ApisixRoute works") + Eventually(request).WithArguments("/get").WithTimeout(8 * time.Second).ProbeEvery(time.Second).Should(Equal(http.StatusOK)) + + By("update ApisixRoute") + applier.MustApplyAPIv2(types.NamespacedName{Namespace: s.Namespace(), Name: "default"}, &apisixRoute, + fmt.Sprintf(apisixRouteSpec, s.Namespace(), "/headers")) + Eventually(request).WithArguments("/get").WithTimeout(8 * time.Second).ProbeEvery(time.Second).Should(Equal(http.StatusNotFound)) + s.RequestAssert(&scaffold.RequestAssert{ + Method: "GET", + Path: "/headers", + Host: "httpbin", + Check: scaffold.WithExpectedStatus(http.StatusOK), + }) + + By("delete ApisixRoute") + err = s.DeleteResource("ApisixRoute", "default") + Expect(err).ShouldNot(HaveOccurred(), "deleting ApisixRoute") + Eventually(request).WithArguments("/headers").WithTimeout(8 * time.Second).ProbeEvery(time.Second).Should(Equal(http.StatusNotFound)) + }) + }) })
