Skip to content

Commit 7972b68

Browse files
committed
fix: r
Signed-off-by: Ashing Zheng <[email protected]>
1 parent 73f842b commit 7972b68

File tree

7 files changed

+55
-259
lines changed

7 files changed

+55
-259
lines changed

test/e2e/crds/v1alpha1/backendtrafficpolicy.go

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,54 +23,12 @@ import (
2323
. "github.com/onsi/ginkgo/v2"
2424
. "github.com/onsi/gomega"
2525

26-
"github.com/apache/apisix-ingress-controller/internal/provider/adc"
27-
"github.com/apache/apisix-ingress-controller/test/e2e/framework"
2826
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
2927
)
3028

3129
var _ = Describe("Test BackendTrafficPolicy base on HTTPRoute", Label("apisix.apache.org", "v1alpha1", "backendtrafficpolicy"), func() {
3230
s := scaffold.NewDefaultScaffold()
3331

34-
var gatewayProxyYaml = `
35-
apiVersion: apisix.apache.org/v1alpha1
36-
kind: GatewayProxy
37-
metadata:
38-
name: apisix-proxy-config
39-
spec:
40-
provider:
41-
type: ControlPlane
42-
controlPlane:
43-
service:
44-
name: %s
45-
port: 9180
46-
auth:
47-
type: AdminKey
48-
adminKey:
49-
value: "%s"
50-
`
51-
var gatewayProxyYamlAPI7 = `
52-
apiVersion: apisix.apache.org/v1alpha1
53-
kind: GatewayProxy
54-
metadata:
55-
name: apisix-proxy-config
56-
spec:
57-
provider:
58-
type: ControlPlane
59-
controlPlane:
60-
endpoints:
61-
- %s
62-
auth:
63-
type: AdminKey
64-
adminKey:
65-
value: "%s"
66-
`
67-
getGatewayProxySpec := func() string {
68-
if s.Deployer.Name() == adc.BackendModeAPI7EE {
69-
return fmt.Sprintf(gatewayProxyYamlAPI7, s.Deployer.GetAdminEndpoint(), s.AdminKey())
70-
}
71-
return fmt.Sprintf(gatewayProxyYaml, framework.ProviderType, s.AdminKey())
72-
}
73-
7432
var defaultGatewayClass = `
7533
apiVersion: gateway.networking.k8s.io/v1
7634
kind: GatewayClass
@@ -150,7 +108,7 @@ spec:
150108
`
151109

152110
BeforeEach(func() {
153-
s.ApplyDefaultGatewayResource(getGatewayProxySpec(), defaultGatewayClass, defaultGateway, defaultHTTPRoute)
111+
s.ApplyDefaultGatewayResource(s.GetGatewayProxySpec(), defaultGatewayClass, defaultGateway, defaultHTTPRoute)
154112
})
155113
It("should rewrite upstream host", func() {
156114
s.ResourceApplied("BackendTrafficPolicy", "httpbin", createUpstreamHost, 1)

test/e2e/crds/v1alpha1/consumer.go

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,53 +25,12 @@ import (
2525
. "github.com/onsi/gomega"
2626

2727
"github.com/apache/apisix-ingress-controller/internal/provider/adc"
28-
"github.com/apache/apisix-ingress-controller/test/e2e/framework"
2928
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
3029
)
3130

3231
var _ = Describe("Test Consumer", Label("apisix.apache.org", "v1alpha1", "consumer"), func() {
3332
s := scaffold.NewDefaultScaffold()
3433

35-
var gatewayProxyYaml = `
36-
apiVersion: apisix.apache.org/v1alpha1
37-
kind: GatewayProxy
38-
metadata:
39-
name: apisix-proxy-config
40-
spec:
41-
provider:
42-
type: ControlPlane
43-
controlPlane:
44-
service:
45-
name: %s
46-
port: 9180
47-
auth:
48-
type: AdminKey
49-
adminKey:
50-
value: "%s"
51-
`
52-
var gatewayProxyYamlAPI7 = `
53-
apiVersion: apisix.apache.org/v1alpha1
54-
kind: GatewayProxy
55-
metadata:
56-
name: apisix-proxy-config
57-
spec:
58-
provider:
59-
type: ControlPlane
60-
controlPlane:
61-
endpoints:
62-
- %s
63-
auth:
64-
type: AdminKey
65-
adminKey:
66-
value: "%s"
67-
`
68-
getGatewayProxySpec := func() string {
69-
if s.Deployer.Name() == adc.BackendModeAPI7EE {
70-
return fmt.Sprintf(gatewayProxyYamlAPI7, s.Deployer.GetAdminEndpoint(), s.AdminKey())
71-
}
72-
return fmt.Sprintf(gatewayProxyYaml, framework.ProviderType, s.AdminKey())
73-
}
74-
7534
var defaultGatewayClass = `
7635
apiVersion: gateway.networking.k8s.io/v1
7736
kind: GatewayClass
@@ -178,7 +137,7 @@ spec:
178137
`
179138

180139
BeforeEach(func() {
181-
s.ApplyDefaultGatewayResource(getGatewayProxySpec(), defaultGatewayClass, defaultGateway, defaultHTTPRoute)
140+
s.ApplyDefaultGatewayResource(s.GetGatewayProxySpec(), defaultGatewayClass, defaultGateway, defaultHTTPRoute)
182141
})
183142

184143
It("limit-count plugin", func() {
@@ -274,7 +233,7 @@ spec:
274233
`
275234

276235
BeforeEach(func() {
277-
s.ApplyDefaultGatewayResource(getGatewayProxySpec(), defaultGatewayClass, defaultGateway, defaultHTTPRoute)
236+
s.ApplyDefaultGatewayResource(s.GetGatewayProxySpec(), defaultGatewayClass, defaultGateway, defaultHTTPRoute)
278237
})
279238

280239
It("Create/Update/Delete", func() {
@@ -423,7 +382,7 @@ spec:
423382
`
424383

425384
BeforeEach(func() {
426-
s.ApplyDefaultGatewayResource(getGatewayProxySpec(), defaultGatewayClass, defaultGateway, defaultHTTPRoute)
385+
s.ApplyDefaultGatewayResource(s.GetGatewayProxySpec(), defaultGatewayClass, defaultGateway, defaultHTTPRoute)
427386
})
428387
It("Create/Update/Delete", func() {
429388
err := s.CreateResourceFromString(keyAuthSecret)
@@ -544,7 +503,7 @@ spec:
544503
`
545504

546505
BeforeEach(func() {
547-
s.ApplyDefaultGatewayResource(getGatewayProxySpec(), defaultGatewayClass, defaultGateway, defaultHTTPRoute)
506+
s.ApplyDefaultGatewayResource(s.GetGatewayProxySpec(), defaultGatewayClass, defaultGateway, defaultHTTPRoute)
548507
})
549508

550509
It("Should sync consumer when GatewayProxy is updated", func() {
@@ -637,7 +596,7 @@ spec:
637596
`
638597

639598
BeforeEach(func() {
640-
s.ApplyDefaultGatewayResource(getGatewayProxySpec(), defaultGatewayClass, defaultGateway, defaultHTTPRoute)
599+
s.ApplyDefaultGatewayResource(s.GetGatewayProxySpec(), defaultGatewayClass, defaultGateway, defaultHTTPRoute)
641600
})
642601

643602
It("Should sync Consumer during startup", func() {

test/e2e/crds/v2/route.go

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -44,46 +44,6 @@ var _ = Describe("Test ApisixRoute", Label("apisix.apache.org", "v2", "apisixrou
4444
applier = framework.NewApplier(s.GinkgoT, s.K8sClient, s.CreateResourceFromString)
4545
)
4646

47-
var gatewayProxyYaml = `
48-
apiVersion: apisix.apache.org/v1alpha1
49-
kind: GatewayProxy
50-
metadata:
51-
name: apisix-proxy-config
52-
spec:
53-
provider:
54-
type: ControlPlane
55-
controlPlane:
56-
service:
57-
name: %s
58-
port: 9180
59-
auth:
60-
type: AdminKey
61-
adminKey:
62-
value: "%s"
63-
`
64-
var gatewayProxyYamlAPI7 = `
65-
apiVersion: apisix.apache.org/v1alpha1
66-
kind: GatewayProxy
67-
metadata:
68-
name: apisix-proxy-config
69-
spec:
70-
provider:
71-
type: ControlPlane
72-
controlPlane:
73-
endpoints:
74-
- %s
75-
auth:
76-
type: AdminKey
77-
adminKey:
78-
value: "%s"
79-
`
80-
getGatewayProxySpec := func() string {
81-
if s.Deployer.Name() == adc.BackendModeAPI7EE {
82-
return fmt.Sprintf(gatewayProxyYamlAPI7, s.Deployer.GetAdminEndpoint(), s.AdminKey())
83-
}
84-
return fmt.Sprintf(gatewayProxyYaml, framework.ProviderType, s.AdminKey())
85-
}
86-
8747
const ingressClassYaml = `
8848
apiVersion: networking.k8s.io/%s
8949
kind: IngressClass
@@ -100,7 +60,7 @@ spec:
10060
`
10161
BeforeEach(func() {
10262
By("create GatewayProxy")
103-
err := s.CreateResourceFromString(getGatewayProxySpec())
63+
err := s.CreateResourceFromString(s.GetGatewayProxySpec())
10464
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
10565
time.Sleep(5 * time.Second)
10666

test/e2e/crds/v2/status.go

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -43,52 +43,10 @@ var _ = Describe("Test apisix.apache.org/v2 Status", Label("apisix.apache.org",
4343
applier = framework.NewApplier(s.GinkgoT, s.K8sClient, s.CreateResourceFromString)
4444
)
4545

46-
var gatewayProxyYaml = `
47-
apiVersion: apisix.apache.org/v1alpha1
48-
kind: GatewayProxy
49-
metadata:
50-
name: apisix-proxy-config
51-
spec:
52-
provider:
53-
type: ControlPlane
54-
controlPlane:
55-
service:
56-
name: %s
57-
port: 9180
58-
auth:
59-
type: AdminKey
60-
adminKey:
61-
value: "%s"
62-
`
63-
64-
var gatewayProxyYamlAPI7 = `
65-
apiVersion: apisix.apache.org/v1alpha1
66-
kind: GatewayProxy
67-
metadata:
68-
name: apisix-proxy-config
69-
spec:
70-
provider:
71-
type: ControlPlane
72-
controlPlane:
73-
endpoints:
74-
- %s
75-
auth:
76-
type: AdminKey
77-
adminKey:
78-
value: "%s"
79-
`
80-
getGatewayProxySpec := func() string {
81-
if s.Deployer.Name() == adc.BackendModeAPI7EE {
82-
return fmt.Sprintf(gatewayProxyYamlAPI7, s.Deployer.GetAdminEndpoint(), s.AdminKey())
83-
}
84-
return fmt.Sprintf(gatewayProxyYaml, framework.ProviderType, s.AdminKey())
85-
}
86-
8746
Context("Test ApisixRoute Sync Status", func() {
8847
BeforeEach(func() {
8948
By("create GatewayProxy")
90-
gatewayProxy := getGatewayProxySpec()
91-
err := s.CreateResourceFromString(gatewayProxy)
49+
err := s.CreateResourceFromString(s.GetGatewayProxySpec())
9250
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
9351
time.Sleep(5 * time.Second)
9452

test/e2e/gatewayapi/httproute.go

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -33,54 +33,13 @@ import (
3333
"sigs.k8s.io/gateway-api/apis/v1alpha2"
3434

3535
"github.com/apache/apisix-ingress-controller/api/v1alpha1"
36-
"github.com/apache/apisix-ingress-controller/internal/provider/adc"
3736
"github.com/apache/apisix-ingress-controller/test/e2e/framework"
3837
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
3938
)
4039

4140
var _ = Describe("Test HTTPRoute", Label("networking.k8s.io", "httproute"), func() {
4241
s := scaffold.NewDefaultScaffold()
4342

44-
var gatewayProxyYaml = `
45-
apiVersion: apisix.apache.org/v1alpha1
46-
kind: GatewayProxy
47-
metadata:
48-
name: apisix-proxy-config
49-
spec:
50-
provider:
51-
type: ControlPlane
52-
controlPlane:
53-
service:
54-
name: %s
55-
port: 9180
56-
auth:
57-
type: AdminKey
58-
adminKey:
59-
value: "%s"
60-
`
61-
var gatewayProxyYamlAPI7 = `
62-
apiVersion: apisix.apache.org/v1alpha1
63-
kind: GatewayProxy
64-
metadata:
65-
name: apisix-proxy-config
66-
spec:
67-
provider:
68-
type: ControlPlane
69-
controlPlane:
70-
endpoints:
71-
- %s
72-
auth:
73-
type: AdminKey
74-
adminKey:
75-
value: "%s"
76-
`
77-
getGatewayProxySpec := func() string {
78-
if s.Deployer.Name() == adc.BackendModeAPI7EE {
79-
return fmt.Sprintf(gatewayProxyYamlAPI7, s.Deployer.GetAdminEndpoint(), s.AdminKey())
80-
}
81-
return fmt.Sprintf(gatewayProxyYaml, framework.ProviderType, s.AdminKey())
82-
}
83-
8443
var gatewayClassYaml = `
8544
apiVersion: gateway.networking.k8s.io/v1
8645
kind: GatewayClass
@@ -132,7 +91,7 @@ spec:
13291
`
13392

13493
var beforeEachHTTP = func() {
135-
Expect(s.CreateResourceFromString(getGatewayProxySpec())).
94+
Expect(s.CreateResourceFromString(s.GetGatewayProxySpec())).
13695
NotTo(HaveOccurred(), "creating GatewayProxy")
13796

13897
gatewayClassName := fmt.Sprintf("apisix-%d", time.Now().Nanosecond())
@@ -167,7 +126,7 @@ spec:
167126

168127
var beforeEachHTTPS = func() {
169128
By("create GatewayProxy")
170-
err := s.CreateResourceFromString(getGatewayProxySpec())
129+
err := s.CreateResourceFromString(s.GetGatewayProxySpec())
171130
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
172131

173132
secretName := _secretName

0 commit comments

Comments
 (0)