You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ro...@apache.org on 2025/09/16 04:01:59 UTC
(apisix-ingress-controller) 01/01: test: unified gatewayproxy yaml acquisition
This is an automated email from the ASF dual-hosted git repository.
ronething pushed a commit to branch test/get_gatewayproxy_spec
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git
commit b0db7855b59132114875140a93a9c096d2d45ef7
Author: Ashing Zheng <ax...@gmail.com>
AuthorDate: Tue Sep 16 12:00:18 2025 +0800
test: unified gatewayproxy yaml acquisition
Signed-off-by: Ashing Zheng <ax...@gmail.com>
---
test/e2e/crds/v1alpha1/backendtrafficpolicy.go | 80 ++-------------
test/e2e/crds/v1alpha1/consumer.go | 42 ++------
test/e2e/crds/v2/consumer.go | 3 +-
test/e2e/crds/v2/globalrule.go | 3 +-
test/e2e/crds/v2/pluginconfig.go | 3 +-
test/e2e/crds/v2/route.go | 3 +-
test/e2e/crds/v2/status.go | 3 +-
test/e2e/crds/v2/streamroute.go | 3 +-
test/e2e/gatewayapi/httproute.go | 72 +++-----------
test/e2e/scaffold/assertion.go | 4 +-
test/e2e/scaffold/k8s.go | 129 +++++++++++++------------
test/e2e/scaffold/scaffold.go | 64 ------------
12 files changed, 106 insertions(+), 303 deletions(-)
diff --git a/test/e2e/crds/v1alpha1/backendtrafficpolicy.go b/test/e2e/crds/v1alpha1/backendtrafficpolicy.go
index 8b918750..d26b6630 100644
--- a/test/e2e/crds/v1alpha1/backendtrafficpolicy.go
+++ b/test/e2e/crds/v1alpha1/backendtrafficpolicy.go
@@ -34,50 +34,6 @@ var _ = Describe("Test BackendTrafficPolicy base on HTTPRoute", Label("apisix.ap
err error
)
- var defaultGatewayProxy = `
-apiVersion: apisix.apache.org/v1alpha1
-kind: GatewayProxy
-metadata:
- name: %s
-spec:
- provider:
- type: ControlPlane
- controlPlane:
- endpoints:
- - %s
- auth:
- type: AdminKey
- adminKey:
- value: "%s"
-`
-
- var defaultGatewayClass = `
-apiVersion: gateway.networking.k8s.io/v1
-kind: GatewayClass
-metadata:
- name: %s
-spec:
- controllerName: %s
-`
-
- var defaultGateway = `
-apiVersion: gateway.networking.k8s.io/v1
-kind: Gateway
-metadata:
- name: %s
-spec:
- gatewayClassName: %s
- listeners:
- - name: http1
- protocol: HTTP
- port: 80
- infrastructure:
- parametersRef:
- group: apisix.apache.org
- kind: GatewayProxy
- name: %s
-`
-
var defaultHTTPRoute = `
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
@@ -133,19 +89,17 @@ spec:
BeforeEach(func() {
gatewayName := s.Namespace()
By("create GatewayProxy")
- gatewayProxyName := gatewayName
- err = s.CreateResourceFromString(fmt.Sprintf(defaultGatewayProxy, gatewayProxyName, s.Deployer.GetAdminEndpoint(), s.AdminKey()))
+ err = s.CreateResourceFromString(s.GetGatewayProxySpec())
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(time.Second)
By("create GatewayClass")
- gatewayClassName := s.Namespace()
- err = s.CreateResourceFromString(fmt.Sprintf(defaultGatewayClass, gatewayClassName, s.GetControllerName()))
+ err = s.CreateResourceFromString(s.GetGatewayClassYaml())
Expect(err).NotTo(HaveOccurred(), "creating GatewayClass")
time.Sleep(time.Second)
By("create Gateway")
- err = s.CreateResourceFromString(fmt.Sprintf(defaultGateway, gatewayName, gatewayClassName, gatewayProxyName))
+ err = s.CreateResourceFromString(s.GetGatewayYaml())
Expect(err).NotTo(HaveOccurred(), "creating Gateway")
time.Sleep(time.Second)
@@ -210,22 +164,6 @@ spec:
var _ = Describe("Test BackendTrafficPolicy base on Ingress", Label("apisix.apache.org", "v1alpha1", "backendtrafficpolicy"), func() {
s := scaffold.NewDefaultScaffold()
- var defaultGatewayProxy = `
-apiVersion: apisix.apache.org/v1alpha1
-kind: GatewayProxy
-metadata:
- name: %s
-spec:
- provider:
- type: ControlPlane
- controlPlane:
- endpoints:
- - %s
- auth:
- type: AdminKey
- adminKey:
- value: "%s"
-`
var defaultIngressClass = `
apiVersion: networking.k8s.io/v1
kind: IngressClass
@@ -234,12 +172,12 @@ metadata:
annotations:
ingressclass.kubernetes.io/is-default-class: "true"
spec:
- controller: "%s"
+ controller: %s
parameters:
apiGroup: "apisix.apache.org"
kind: "GatewayProxy"
- name: "%s"
- namespace: "%s"
+ name: "apisix-proxy-config"
+ namespace: %s
scope: "Namespace"
`
@@ -263,13 +201,11 @@ spec:
`
var beforeEach = func() {
By("create GatewayProxy")
- gatewayProxyName := s.Namespace()
- gatewayProxy := fmt.Sprintf(defaultGatewayProxy, gatewayProxyName, s.Deployer.GetAdminEndpoint(), s.AdminKey())
- err := s.CreateResourceFromString(gatewayProxy)
+ err := s.CreateResourceFromString(s.GetGatewayProxySpec())
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
By("create IngressClass with GatewayProxy reference")
- err = s.CreateResourceFromString(fmt.Sprintf(defaultIngressClass, s.GetControllerName(), gatewayProxyName, s.Namespace()))
+ err = s.CreateResourceFromString(fmt.Sprintf(defaultIngressClass, s.GetControllerName(), s.Namespace()))
Expect(err).NotTo(HaveOccurred(), "creating IngressClass with GatewayProxy")
By("create Ingress with GatewayProxy IngressClass")
diff --git a/test/e2e/crds/v1alpha1/consumer.go b/test/e2e/crds/v1alpha1/consumer.go
index 671fdb16..6891d3bd 100644
--- a/test/e2e/crds/v1alpha1/consumer.go
+++ b/test/e2e/crds/v1alpha1/consumer.go
@@ -38,7 +38,7 @@ var _ = Describe("Test Consumer", Label("apisix.apache.org", "v1alpha1", "consum
apiVersion: apisix.apache.org/v1alpha1
kind: GatewayProxy
metadata:
- name: %s
+ name: apisix-proxy-config
spec:
provider:
type: ControlPlane
@@ -51,33 +51,6 @@ spec:
value: "%s"
`
- var defaultGatewayClass = `
-apiVersion: gateway.networking.k8s.io/v1
-kind: GatewayClass
-metadata:
- name: %s
-spec:
- controllerName: %s
-`
-
- var defaultGateway = `
-apiVersion: gateway.networking.k8s.io/v1
-kind: Gateway
-metadata:
- name: %s
-spec:
- gatewayClassName: %s
- listeners:
- - name: http1
- protocol: HTTP
- port: 80
- infrastructure:
- parametersRef:
- group: apisix.apache.org
- kind: GatewayProxy
- name: %s
-`
-
var defaultHTTPRoute = `
apiVersion: apisix.apache.org/v1alpha1
kind: PluginConfig
@@ -119,26 +92,23 @@ spec:
`
BeforeEach(func() {
- gatewayName := s.Namespace()
- By("create GatewayProxy")
- gatewayProxyName := s.Namespace()
- err = s.CreateResourceFromStringWithNamespace(fmt.Sprintf(defaultGatewayProxy, gatewayProxyName, s.Deployer.GetAdminEndpoint(), s.AdminKey()), s.Namespace())
+ By("create GatewayProxy, control plane using endpoints")
+ err = s.CreateResourceFromString(fmt.Sprintf(defaultGatewayProxy, s.Deployer.GetAdminEndpoint(), s.AdminKey()))
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(time.Second)
By("create GatewayClass")
- gatewayClassName := s.Namespace()
- err = s.CreateResourceFromString(fmt.Sprintf(defaultGatewayClass, gatewayClassName, s.GetControllerName()))
+ err = s.CreateResourceFromString(s.GetGatewayClassYaml())
Expect(err).NotTo(HaveOccurred(), "creating GatewayClass")
time.Sleep(time.Second)
By("create Gateway")
- err = s.CreateResourceFromStringWithNamespace(fmt.Sprintf(defaultGateway, gatewayName, gatewayClassName, gatewayProxyName), s.Namespace())
+ err = s.CreateResourceFromString(s.GetGatewayYaml())
Expect(err).NotTo(HaveOccurred(), "creating Gateway")
time.Sleep(time.Second)
By("create HTTPRoute")
- s.ApplyHTTPRoute(types.NamespacedName{Namespace: s.Namespace(), Name: "httpbin"}, fmt.Sprintf(defaultHTTPRoute, gatewayName))
+ s.ApplyHTTPRoute(types.NamespacedName{Namespace: s.Namespace(), Name: "httpbin"}, fmt.Sprintf(defaultHTTPRoute, s.Namespace()))
})
Context("Consumer plugins", func() {
diff --git a/test/e2e/crds/v2/consumer.go b/test/e2e/crds/v2/consumer.go
index a670c71a..b7b59ef9 100644
--- a/test/e2e/crds/v2/consumer.go
+++ b/test/e2e/crds/v2/consumer.go
@@ -66,8 +66,7 @@ var _ = Describe("Test ApisixConsumer", Label("apisix.apache.org", "v2", "apisix
BeforeEach(func() {
By("create GatewayProxy")
- gatewayProxy := s.GetGatewayProxyYaml()
- err := s.CreateResourceFromString(gatewayProxy)
+ err := s.CreateResourceFromString(s.GetGatewayProxySpec())
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
diff --git a/test/e2e/crds/v2/globalrule.go b/test/e2e/crds/v2/globalrule.go
index 70e44ab1..6a72a12b 100644
--- a/test/e2e/crds/v2/globalrule.go
+++ b/test/e2e/crds/v2/globalrule.go
@@ -54,8 +54,7 @@ spec:
Context("ApisixGlobalRule Basic Operations", func() {
BeforeEach(func() {
By("create GatewayProxy")
- gatewayProxy := s.GetGatewayProxyYaml()
- err := s.CreateResourceFromString(gatewayProxy)
+ err := s.CreateResourceFromString(s.GetGatewayProxySpec())
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
diff --git a/test/e2e/crds/v2/pluginconfig.go b/test/e2e/crds/v2/pluginconfig.go
index 7b0196e4..250bb5a2 100644
--- a/test/e2e/crds/v2/pluginconfig.go
+++ b/test/e2e/crds/v2/pluginconfig.go
@@ -40,8 +40,7 @@ var _ = Describe("Test ApisixPluginConfig", Label("apisix.apache.org", "v2", "ap
Context("Test ApisixPluginConfig", func() {
BeforeEach(func() {
By("create GatewayProxy")
- gatewayProxy := s.GetGatewayProxyYaml()
- err := s.CreateResourceFromString(gatewayProxy)
+ err := s.CreateResourceFromString(s.GetGatewayProxySpec())
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
diff --git a/test/e2e/crds/v2/route.go b/test/e2e/crds/v2/route.go
index eacf0f05..ef413099 100644
--- a/test/e2e/crds/v2/route.go
+++ b/test/e2e/crds/v2/route.go
@@ -48,8 +48,7 @@ var _ = Describe("Test ApisixRoute", Label("apisix.apache.org", "v2", "apisixrou
BeforeEach(func() {
By("create GatewayProxy")
- gatewayProxy := s.GetGatewayProxyYaml()
- err := s.CreateResourceFromString(gatewayProxy)
+ err := s.CreateResourceFromString(s.GetGatewayProxySpec())
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
diff --git a/test/e2e/crds/v2/status.go b/test/e2e/crds/v2/status.go
index 7b7defe6..74db297f 100644
--- a/test/e2e/crds/v2/status.go
+++ b/test/e2e/crds/v2/status.go
@@ -42,8 +42,7 @@ var _ = Describe("Test CRD Status", Label("apisix.apache.org", "v2", "apisixrout
Context("Test ApisixRoute Sync Status", func() {
BeforeEach(func() {
By("create GatewayProxy")
- gatewayProxy := s.GetGatewayProxyWithServiceYaml()
- err := s.CreateResourceFromString(gatewayProxy)
+ err := s.CreateResourceFromString(s.GetGatewayProxySpec())
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
diff --git a/test/e2e/crds/v2/streamroute.go b/test/e2e/crds/v2/streamroute.go
index 550754b2..1a28bc56 100644
--- a/test/e2e/crds/v2/streamroute.go
+++ b/test/e2e/crds/v2/streamroute.go
@@ -37,8 +37,7 @@ var _ = Describe("Test ApisixRoute With StreamRoute", Label("apisix.apache.org",
Skip("only support APISIX provider")
}
By("create GatewayProxy")
- gatewayProxy := s.GetGatewayProxyYaml()
- err := s.CreateResourceFromString(gatewayProxy)
+ err := s.CreateResourceFromString(s.GetGatewayProxySpec())
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
diff --git a/test/e2e/gatewayapi/httproute.go b/test/e2e/gatewayapi/httproute.go
index 4dfe6e09..f59523ee 100644
--- a/test/e2e/gatewayapi/httproute.go
+++ b/test/e2e/gatewayapi/httproute.go
@@ -49,27 +49,6 @@ func applyHTTPRouteAndAssert(s *scaffold.Scaffold, route string, asserts []scaff
var _ = Describe("Test HTTPRoute", Label("networking.k8s.io", "httproute"), func() {
s := scaffold.NewDefaultScaffold()
- var gatewayProxyYaml = `
-apiVersion: apisix.apache.org/v1alpha1
-kind: GatewayProxy
-metadata:
- name: %s
-spec:
- provider:
- type: ControlPlane
- controlPlane:
- service:
- name: %s
- port: 9180
- auth:
- type: AdminKey
- adminKey:
- value: "%s"
-`
- getGatewayProxySpec := func() string {
- return fmt.Sprintf(gatewayProxyYaml, s.Namespace(), framework.ProviderType, s.AdminKey())
- }
-
var gatewayClassYaml = `
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
@@ -79,23 +58,6 @@ spec:
controllerName: %s
`
- var defaultGateway = `
-apiVersion: gateway.networking.k8s.io/v1
-kind: Gateway
-metadata:
- name: %s
-spec:
- gatewayClassName: %s
- listeners:
- - name: http1
- protocol: HTTP
- port: 80
- infrastructure:
- parametersRef:
- group: apisix.apache.org
- kind: GatewayProxy
- name: %s
-`
var defaultGatewayHTTPS = `
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
@@ -117,19 +79,18 @@ spec:
parametersRef:
group: apisix.apache.org
kind: GatewayProxy
- name: %s
+ name: apisix-proxy-config
`
var beforeEachHTTP = func() {
- Expect(s.CreateResourceFromStringWithNamespace(getGatewayProxySpec(), s.Namespace())).
- NotTo(HaveOccurred(), "creating GatewayProxy")
+ By("create GatewayProxy")
+ Expect(s.CreateResourceFromString(s.GetGatewayProxySpec())).NotTo(HaveOccurred(), "creating GatewayProxy")
- gatewayClassName := s.Namespace()
- Expect(s.CreateResourceFromStringWithNamespace(fmt.Sprintf(gatewayClassYaml, gatewayClassName, s.GetControllerName()), "")).
- NotTo(HaveOccurred(), "creating GatewayClass")
+ By("create GatewayClass")
+ Expect(s.CreateResourceFromString(s.GetGatewayClassYaml())).NotTo(HaveOccurred(), "creating GatewayClass")
s.RetryAssertion(func() string {
- gcyaml, _ := s.GetResourceYaml("GatewayClass", gatewayClassName)
+ gcyaml, _ := s.GetResourceYaml("GatewayClass", s.Namespace())
return gcyaml
}).Should(
And(
@@ -138,12 +99,12 @@ spec:
),
"check GatewayClass condition",
)
- gatewayName := s.Namespace()
- Expect(s.CreateResourceFromStringWithNamespace(fmt.Sprintf(defaultGateway, gatewayName, gatewayClassName, s.Namespace()), s.Namespace())).
- NotTo(HaveOccurred(), "creating Gateway")
+
+ By("create Gateway")
+ Expect(s.CreateResourceFromString(s.GetGatewayYaml())).NotTo(HaveOccurred(), "creating Gateway")
s.RetryAssertion(func() string {
- gcyaml, _ := s.GetResourceYaml("Gateway", gatewayName)
+ gcyaml, _ := s.GetResourceYaml("Gateway", s.Namespace())
return gcyaml
}).Should(
And(
@@ -156,19 +117,17 @@ spec:
var beforeEachHTTPS = func() {
By("create GatewayProxy")
- err := s.CreateResourceFromStringWithNamespace(getGatewayProxySpec(), s.Namespace())
+ err := s.CreateResourceFromString(s.GetGatewayProxySpec())
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
secretName := _secretName
createSecret(s, secretName)
By("create GatewayClass")
- gatewayClassName := s.Namespace()
- Expect(s.CreateResourceFromStringWithNamespace(fmt.Sprintf(gatewayClassYaml, gatewayClassName, s.GetControllerName()), "")).
- NotTo(HaveOccurred(), "creating GatewayClass")
+ Expect(s.CreateResourceFromString(s.GetGatewayClassYaml())).NotTo(HaveOccurred(), "creating GatewayClass")
s.RetryAssertion(func() string {
- gcyaml, _ := s.GetResourceYaml("GatewayClass", gatewayClassName)
+ gcyaml, _ := s.GetResourceYaml("GatewayClass", s.Namespace())
return gcyaml
}).Should(
And(
@@ -179,12 +138,11 @@ spec:
)
By("create Gateway")
- gatewayName := s.Namespace()
- err = s.CreateResourceFromStringWithNamespace(fmt.Sprintf(defaultGatewayHTTPS, gatewayName, gatewayClassName, s.Namespace()), s.Namespace())
+ err = s.CreateResourceFromString(fmt.Sprintf(defaultGatewayHTTPS, s.Namespace(), s.Namespace()))
Expect(err).NotTo(HaveOccurred(), "creating Gateway")
s.RetryAssertion(func() string {
- gcyaml, _ := s.GetResourceYaml("Gateway", gatewayName)
+ gcyaml, _ := s.GetResourceYaml("Gateway", s.Namespace())
return gcyaml
}).Should(
And(
diff --git a/test/e2e/scaffold/assertion.go b/test/e2e/scaffold/assertion.go
index b17cab6b..ec0d2f21 100644
--- a/test/e2e/scaffold/assertion.go
+++ b/test/e2e/scaffold/assertion.go
@@ -40,11 +40,11 @@ type ErrorReporter struct {
err error
}
-func (r *ErrorReporter) Errorf(message string, args ...interface{}) {
+func (r *ErrorReporter) Errorf(message string, args ...any) {
r.err = fmt.Errorf(message, args...)
}
-func (r *ErrorReporter) Fatalf(message string, args ...interface{}) {
+func (r *ErrorReporter) Fatalf(message string, args ...any) {
r.err = fmt.Errorf(message, args...)
}
diff --git a/test/e2e/scaffold/k8s.go b/test/e2e/scaffold/k8s.go
index 50d1cd2f..732da0da 100644
--- a/test/e2e/scaffold/k8s.go
+++ b/test/e2e/scaffold/k8s.go
@@ -197,51 +197,6 @@ func (s *Scaffold) ResourceApplied(resourType, resourceName, resourceRaw string,
)
}
-func (s *Scaffold) ApplyDefaultGatewayResource(
- defaultGatewayProxy string,
- defaultGatewayClass string,
- defaultGateway string,
- defaultHTTPRoute string,
-) {
- By("create GatewayProxy")
- gatewayProxy := fmt.Sprintf(defaultGatewayProxy, s.Deployer.GetAdminEndpoint(), s.AdminKey())
- err := s.CreateResourceFromString(gatewayProxy)
- Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
- time.Sleep(5 * time.Second)
-
- By("create GatewayClass")
- gatewayClassName := s.Namespace()
- gatewayString := fmt.Sprintf(defaultGatewayClass, gatewayClassName, s.GetControllerName())
- err = s.CreateResourceFromStringWithNamespace(gatewayString, "")
- Expect(err).NotTo(HaveOccurred(), "creating GatewayClass")
- time.Sleep(5 * time.Second)
-
- By("check GatewayClass condition")
- gcyaml, err := s.GetResourceYaml("GatewayClass", gatewayClassName)
- Expect(err).NotTo(HaveOccurred(), "getting GatewayClass yaml")
- Expect(gcyaml).To(ContainSubstring(`status: "True"`), "checking GatewayClass condition status")
- Expect(gcyaml).To(
- ContainSubstring("message: the gatewayclass has been accepted by the apisix-ingress-controller"),
- "checking GatewayClass condition message",
- )
-
- By("create Gateway")
- err = s.CreateResourceFromStringWithNamespace(fmt.Sprintf(defaultGateway, gatewayClassName), s.Namespace())
- Expect(err).NotTo(HaveOccurred(), "creating Gateway")
- time.Sleep(5 * time.Second)
-
- By("check Gateway condition")
- gwyaml, err := s.GetResourceYaml("Gateway", "apisix")
- Expect(err).NotTo(HaveOccurred(), "getting Gateway yaml")
- Expect(gwyaml).To(ContainSubstring(`status: "True"`), "checking Gateway condition status")
- Expect(gwyaml).To(
- ContainSubstring("message: the gateway has been accepted by the apisix-ingress-controller"),
- "checking Gateway condition message",
- )
-
- s.ResourceApplied("httproute", "httpbin", defaultHTTPRoute, 1)
-}
-
func (s *Scaffold) ApplyHTTPRoute(hrNN types.NamespacedName, spec string, until ...wait.ConditionWithContextFunc) {
err := s.CreateResourceFromString(spec)
Expect(err).NotTo(HaveOccurred(), "creating HTTPRoute %s", hrNN)
@@ -275,6 +230,25 @@ func (s *Scaffold) ApplyHTTPRoutePolicy(refNN, hrpNN types.NamespacedName, spec
}
}
+func (s *Scaffold) WaitUntilDeploymentAvailable(name string) {
+ k8s.WaitUntilDeploymentAvailable(s.GinkgoT, s.kubectlOptions, name, 10, 10*time.Second)
+}
+
+func (s *Scaffold) RunDigDNSClientFromK8s(args ...string) (string, error) {
+ kubectlArgs := []string{
+ "run",
+ "dig",
+ "-i",
+ "--rm",
+ "--restart=Never",
+ "--image-pull-policy=IfNotPresent",
+ "--image=toolbelt/dig",
+ "--",
+ }
+ kubectlArgs = append(kubectlArgs, args...)
+ return s.RunKubectlAndGetOutput(kubectlArgs...)
+}
+
func (s *Scaffold) GetGatewayProxySpec() string {
var gatewayProxyYaml = `
apiVersion: apisix.apache.org/v1alpha1
@@ -296,21 +270,56 @@ spec:
return fmt.Sprintf(gatewayProxyYaml, framework.ProviderType, s.AdminKey())
}
-func (s *Scaffold) WaitUntilDeploymentAvailable(name string) {
- k8s.WaitUntilDeploymentAvailable(s.GinkgoT, s.kubectlOptions, name, 10, 10*time.Second)
+const ingressClassYaml = `
+apiVersion: networking.k8s.io/v1
+kind: IngressClass
+metadata:
+ name: %s
+spec:
+ controller: %s
+ parameters:
+ apiGroup: "apisix.apache.org"
+ kind: "GatewayProxy"
+ name: "apisix-proxy-config"
+ namespace: %s
+ scope: Namespace
+`
+
+func (s *Scaffold) GetIngressClassYaml() string {
+ return fmt.Sprintf(ingressClassYaml, s.Namespace(), s.GetControllerName(), s.Namespace())
}
-func (s *Scaffold) RunDigDNSClientFromK8s(args ...string) (string, error) {
- kubectlArgs := []string{
- "run",
- "dig",
- "-i",
- "--rm",
- "--restart=Never",
- "--image-pull-policy=IfNotPresent",
- "--image=toolbelt/dig",
- "--",
- }
- kubectlArgs = append(kubectlArgs, args...)
- return s.RunKubectlAndGetOutput(kubectlArgs...)
+const gatewayClassYaml = `
+apiVersion: gateway.networking.k8s.io/v1
+kind: GatewayClass
+metadata:
+ name: %s
+spec:
+ controllerName: %s
+`
+
+func (s *Scaffold) GetGatewayClassYaml() string {
+ return fmt.Sprintf(gatewayClassYaml, s.Namespace(), s.GetControllerName())
+}
+
+const gatewayYaml = `
+apiVersion: gateway.networking.k8s.io/v1
+kind: Gateway
+metadata:
+ name: %s
+spec:
+ gatewayClassName: %s
+ listeners:
+ - name: http1
+ protocol: HTTP
+ port: 80
+ infrastructure:
+ parametersRef:
+ group: apisix.apache.org
+ kind: GatewayProxy
+ name: apisix-proxy-config
+`
+
+func (s *Scaffold) GetGatewayYaml() string {
+ return fmt.Sprintf(gatewayYaml, s.Namespace(), s.Namespace())
}
diff --git a/test/e2e/scaffold/scaffold.go b/test/e2e/scaffold/scaffold.go
index e8fa6fbc..e41aacbb 100644
--- a/test/e2e/scaffold/scaffold.go
+++ b/test/e2e/scaffold/scaffold.go
@@ -492,67 +492,3 @@ func (s *Scaffold) GetMetricsEndpoint() string {
s.addFinalizers(tunnel.Close)
return fmt.Sprintf("http://%s/metrics", tunnel.Endpoint())
}
-
-const gatewayProxyYaml = `
-apiVersion: apisix.apache.org/v1alpha1
-kind: GatewayProxy
-metadata:
- name: %s
- namespace: %s
-spec:
- provider:
- type: ControlPlane
- controlPlane:
- endpoints:
- - %s
- auth:
- type: AdminKey
- adminKey:
- value: "%s"
-`
-
-const gatewayProxyWithServiceYaml = `
-apiVersion: apisix.apache.org/v1alpha1
-kind: GatewayProxy
-metadata:
- name: %s
- namespace: %s
-spec:
- provider:
- type: ControlPlane
- controlPlane:
- service:
- name: %s
- port: 9180
- auth:
- type: AdminKey
- adminKey:
- value: "%s"
-`
-
-const ingressClassYaml = `
-apiVersion: networking.k8s.io/v1
-kind: IngressClass
-metadata:
- name: %s
-spec:
- controller: %s
- parameters:
- apiGroup: "apisix.apache.org"
- kind: "GatewayProxy"
- name: "%s"
- namespace: "%s"
- scope: "Namespace"
-`
-
-func (s *Scaffold) GetGatewayProxyYaml() string {
- return fmt.Sprintf(gatewayProxyYaml, s.namespace, s.namespace, s.Deployer.GetAdminEndpoint(), s.AdminKey())
-}
-
-func (s *Scaffold) GetGatewayProxyWithServiceYaml() string {
- return fmt.Sprintf(gatewayProxyWithServiceYaml, s.namespace, s.namespace, s.dataplaneService.Name, s.AdminKey())
-}
-
-func (s *Scaffold) GetIngressClassYaml() string {
- return fmt.Sprintf(ingressClassYaml, s.namespace, s.GetControllerName(), s.namespace, s.namespace)
-}