Skip to content

Commit 2fa5952

Browse files
committed
fix: r
Signed-off-by: Ashing Zheng <[email protected]>
1 parent 43c06c3 commit 2fa5952

File tree

5 files changed

+62
-152
lines changed

5 files changed

+62
-152
lines changed

.github/workflows/e2e-test-k8s.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
name: E2E Test For Kubernetes
18+
name: API7EE E2E Test For Kubernetes 1.18
1919

2020
on:
2121
push:

.github/workflows/e2e-test.yml

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
name: E2E Test
18+
name: API7EE E2E Test
1919

2020
on:
2121
push:
@@ -29,32 +29,7 @@ concurrency:
2929
cancel-in-progress: true
3030

3131
jobs:
32-
prepare:
33-
name: Prepare
34-
runs-on: ubuntu-latest
35-
steps:
36-
- name: Checkout
37-
uses: actions/checkout@v4
38-
39-
- name: Setup Go Env
40-
id: go
41-
uses: actions/setup-go@v4
42-
with:
43-
go-version: "1.23"
44-
45-
- name: Install kind
46-
run: |
47-
go install sigs.k8s.io/[email protected]
48-
49-
- name: Install Helm
50-
run: |
51-
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
52-
chmod 700 get_helm.sh
53-
./get_helm.sh
54-
5532
e2e-test:
56-
needs:
57-
- prepare
5833
strategy:
5934
matrix:
6035
cases_subset:
@@ -73,6 +48,15 @@ jobs:
7348
with:
7449
go-version: "1.23"
7550

51+
- name: Install kind
52+
run: |
53+
go install sigs.k8s.io/[email protected]
54+
55+
- name: Install Helm
56+
run: |
57+
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
58+
chmod 700 get_helm.sh
59+
./get_helm.sh
7660
- name: Login to Registry
7761
uses: docker/login-action@v3
7862
with:

test/e2e/crds/v1alpha1/gatewayproxy.go

Lines changed: 32 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ var _ = Describe("Test GatewayProxy", Label("apisix.apache.org", "v1alpha1", "ga
4040
err error
4141
)
4242

43-
// TODO: change E2E
44-
const gatewayProxySpecAPI7 = `
43+
const gatewayProxySpec = `
4544
apiVersion: apisix.apache.org/v1alpha1
4645
kind: GatewayProxy
4746
metadata:
@@ -50,8 +49,9 @@ spec:
5049
provider:
5150
type: ControlPlane
5251
controlPlane:
53-
endpoints:
54-
- %s
52+
service:
53+
name: %s
54+
port: 9180
5555
auth:
5656
type: AdminKey
5757
adminKey:
@@ -64,31 +64,29 @@ spec:
6464
"X-Pod-Hostname": "$hostname"
6565
`
6666

67-
const gatewayClassSpec = `
68-
apiVersion: gateway.networking.k8s.io/v1
69-
kind: GatewayClass
70-
metadata:
71-
name: %s
72-
spec:
73-
controllerName: %s
74-
`
75-
const gatewaySpec = `
76-
apiVersion: gateway.networking.k8s.io/v1
77-
kind: Gateway
67+
const gatewayProxySpecAPI7 = `
68+
apiVersion: apisix.apache.org/v1alpha1
69+
kind: GatewayProxy
7870
metadata:
79-
name: %s
71+
name: apisix-proxy-config
8072
spec:
81-
gatewayClassName: %s
82-
listeners:
83-
- name: http1
84-
protocol: HTTP
85-
port: 80
86-
infrastructure:
87-
parametersRef:
88-
group: apisix.apache.org
89-
kind: GatewayProxy
90-
name: apisix-proxy-config
73+
provider:
74+
type: ControlPlane
75+
controlPlane:
76+
endpoints:
77+
- %s
78+
auth:
79+
type: AdminKey
80+
adminKey:
81+
value: "%s"
82+
plugins:
83+
- name: response-rewrite
84+
enabled: true
85+
config:
86+
headers:
87+
"X-Pod-Hostname": "$hostname"
9188
`
89+
9290
const httpRouteSpec = `
9391
apiVersion: gateway.networking.k8s.io/v1
9492
kind: HTTPRoute
@@ -109,30 +107,6 @@ spec:
109107
port: 80
110108
`
111109

112-
const gatewayProxySpec = `
113-
apiVersion: apisix.apache.org/v1alpha1
114-
kind: GatewayProxy
115-
metadata:
116-
name: apisix-proxy-config
117-
spec:
118-
provider:
119-
type: ControlPlane
120-
controlPlane:
121-
service:
122-
name: %s
123-
port: 9180
124-
auth:
125-
type: AdminKey
126-
adminKey:
127-
value: "%s"
128-
plugins:
129-
- name: response-rewrite
130-
enabled: true
131-
config:
132-
headers:
133-
"X-Pod-Hostname": "$hostname"
134-
`
135-
136110
BeforeEach(func() {
137111
gatewayName := s.Namespace()
138112
By("create GatewayProxy")
@@ -141,21 +115,18 @@ spec:
141115
} else {
142116
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxySpec, framework.ProviderType, s.AdminKey()))
143117
}
144-
gatewayProxy := fmt.Sprintf(gatewayProxySpec, framework.ProviderType, s.AdminKey())
145-
err = s.CreateResourceFromString(gatewayProxy)
146118
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
147-
time.Sleep(time.Second)
119+
time.Sleep(5 * time.Second)
148120

149121
By("create GatewayClass")
150-
gatewayClassName := s.Namespace()
151-
err = s.CreateResourceFromString(fmt.Sprintf(gatewayClassSpec, gatewayClassName, s.GetControllerName()))
122+
err = s.CreateResourceFromString(s.GetGatewayClassYaml())
152123
Expect(err).NotTo(HaveOccurred(), "creating GatewayClass")
153-
time.Sleep(time.Second)
124+
time.Sleep(5 * time.Second)
154125

155126
By("create Gateway")
156-
err = s.CreateResourceFromString(fmt.Sprintf(gatewaySpec, gatewayName, gatewayClassName))
127+
err = s.CreateResourceFromString(s.GetGatewayYaml())
157128
Expect(err).NotTo(HaveOccurred(), "creating Gateway")
158-
time.Sleep(time.Second)
129+
time.Sleep(5 * time.Second)
159130

160131
By("create HTTPRoute")
161132
s.ApplyHTTPRoute(types.NamespacedName{Namespace: s.Namespace(), Name: "httpbin"}, fmt.Sprintf(httpRouteSpec, gatewayName))
@@ -213,10 +184,10 @@ spec:
213184
keyword string
214185
)
215186

216-
if framework.ProviderType == framework.ProviderTypeAPISIX {
217-
keyword = fmt.Sprintf(`{"config.ServerAddrs": ["%s"]}`, s.Deployer.GetAdminEndpoint())
218-
} else {
187+
if framework.ProviderType == framework.ProviderTypeAPISIXStandalone {
219188
keyword = fmt.Sprintf(`{"config.ServerAddrs": ["http://%s:9180"]}`, s.GetPodIP(s.Namespace(), "app.kubernetes.io/name=apisix"))
189+
} else {
190+
keyword = fmt.Sprintf(`{"config.ServerAddrs": ["%s"]}`, s.Deployer.GetAdminEndpoint())
220191
}
221192

222193
By(fmt.Sprintf("wait for keyword: %s", keyword))

test/e2e/crds/v2/route.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,6 @@ spec:
13861386
It("should be able to use backends and upstreams together", func() {
13871387
upstreamName := s.Namespace()
13881388
routeName := s.Namespace()
1389-
// TODO: change ingressClassName
13901389
upstreamSpec := `
13911390
apiVersion: apisix.apache.org/v2
13921391
kind: ApisixUpstream

test/e2e/gatewayapi/httproute.go

Lines changed: 19 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,6 @@ import (
4040
var _ = Describe("Test HTTPRoute", Label("networking.k8s.io", "httproute"), func() {
4141
s := scaffold.NewDefaultScaffold()
4242

43-
var gatewayProxyYaml = `
44-
apiVersion: apisix.apache.org/v1alpha1
45-
kind: GatewayProxy
46-
metadata:
47-
name: %s
48-
spec:
49-
provider:
50-
type: ControlPlane
51-
controlPlane:
52-
service:
53-
name: %s
54-
port: 9180
55-
auth:
56-
type: AdminKey
57-
adminKey:
58-
value: "%s"
59-
`
60-
getGatewayProxySpec := func() string {
61-
return fmt.Sprintf(gatewayProxyYaml, s.Namespace(), framework.ProviderType, s.AdminKey())
62-
}
63-
6443
var gatewayClassYaml = `
6544
apiVersion: gateway.networking.k8s.io/v1
6645
kind: GatewayClass
@@ -70,23 +49,6 @@ spec:
7049
controllerName: %s
7150
`
7251

73-
var defaultGateway = `
74-
apiVersion: gateway.networking.k8s.io/v1
75-
kind: Gateway
76-
metadata:
77-
name: %s
78-
spec:
79-
gatewayClassName: %s
80-
listeners:
81-
- name: http1
82-
protocol: HTTP
83-
port: 80
84-
infrastructure:
85-
parametersRef:
86-
group: apisix.apache.org
87-
kind: GatewayProxy
88-
name: %s
89-
`
9052
var defaultGatewayHTTPS = `
9153
apiVersion: gateway.networking.k8s.io/v1
9254
kind: Gateway
@@ -108,19 +70,18 @@ spec:
10870
parametersRef:
10971
group: apisix.apache.org
11072
kind: GatewayProxy
111-
name: %s
73+
name: apisix-proxy-config
11274
`
11375

11476
var beforeEachHTTP = func() {
115-
Expect(s.CreateResourceFromStringWithNamespace(getGatewayProxySpec(), s.Namespace())).
116-
NotTo(HaveOccurred(), "creating GatewayProxy")
77+
By("create GatewayProxy")
78+
Expect(s.CreateResourceFromString(s.GetGatewayProxySpec())).NotTo(HaveOccurred(), "creating GatewayProxy")
11779

118-
gatewayClassName := s.Namespace()
119-
Expect(s.CreateResourceFromStringWithNamespace(fmt.Sprintf(gatewayClassYaml, gatewayClassName, s.GetControllerName()), "")).
120-
NotTo(HaveOccurred(), "creating GatewayClass")
80+
By("create GatewayClass")
81+
Expect(s.CreateResourceFromString(s.GetGatewayClassYaml())).NotTo(HaveOccurred(), "creating GatewayClass")
12182

12283
s.RetryAssertion(func() string {
123-
gcyaml, _ := s.GetResourceYaml("GatewayClass", gatewayClassName)
84+
gcyaml, _ := s.GetResourceYaml("GatewayClass", s.Namespace())
12485
return gcyaml
12586
}).Should(
12687
And(
@@ -129,12 +90,11 @@ spec:
12990
),
13091
"check GatewayClass condition",
13192
)
132-
gatewayName := s.Namespace()
133-
Expect(s.CreateResourceFromStringWithNamespace(fmt.Sprintf(defaultGateway, gatewayName, gatewayClassName, s.Namespace()), s.Namespace())).
134-
NotTo(HaveOccurred(), "creating Gateway")
93+
94+
Expect(s.CreateResourceFromString(s.GetGatewayYaml())).NotTo(HaveOccurred(), "creating Gateway")
13595

13696
s.RetryAssertion(func() string {
137-
gcyaml, _ := s.GetResourceYaml("Gateway", gatewayName)
97+
gcyaml, _ := s.GetResourceYaml("Gateway", s.Namespace())
13898
return gcyaml
13999
}).Should(
140100
And(
@@ -147,19 +107,17 @@ spec:
147107

148108
var beforeEachHTTPS = func() {
149109
By("create GatewayProxy")
150-
err := s.CreateResourceFromStringWithNamespace(getGatewayProxySpec(), s.Namespace())
110+
err := s.CreateResourceFromString(s.GetGatewayProxySpec())
151111
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
152112

153113
secretName := _secretName
154114
createSecret(s, secretName)
155115

156116
By("create GatewayClass")
157-
gatewayClassName := s.Namespace()
158-
Expect(s.CreateResourceFromStringWithNamespace(fmt.Sprintf(gatewayClassYaml, gatewayClassName, s.GetControllerName()), "")).
159-
NotTo(HaveOccurred(), "creating GatewayClass")
117+
Expect(s.CreateResourceFromString(s.GetGatewayClassYaml())).NotTo(HaveOccurred(), "creating GatewayClass")
160118

161119
s.RetryAssertion(func() string {
162-
gcyaml, _ := s.GetResourceYaml("GatewayClass", gatewayClassName)
120+
gcyaml, _ := s.GetResourceYaml("GatewayClass", s.Namespace())
163121
return gcyaml
164122
}).Should(
165123
And(
@@ -170,12 +128,11 @@ spec:
170128
)
171129

172130
By("create Gateway")
173-
gatewayName := s.Namespace()
174-
err = s.CreateResourceFromStringWithNamespace(fmt.Sprintf(defaultGatewayHTTPS, gatewayName, gatewayClassName, s.Namespace()), s.Namespace())
131+
err = s.CreateResourceFromString(fmt.Sprintf(defaultGatewayHTTPS, s.Namespace(), s.Namespace()))
175132
Expect(err).NotTo(HaveOccurred(), "creating Gateway")
176133

177134
s.RetryAssertion(func() string {
178-
gcyaml, _ := s.GetResourceYaml("Gateway", gatewayName)
135+
gcyaml, _ := s.GetResourceYaml("Gateway", s.Namespace())
179136
return gcyaml
180137
}).Should(
181138
And(
@@ -1853,7 +1810,7 @@ spec:
18531810
apiVersion: apisix.apache.org/v1alpha1
18541811
kind: GatewayProxy
18551812
metadata:
1856-
name: %s
1813+
name: apisix-proxy-config
18571814
spec:
18581815
provider:
18591816
type: ControlPlane
@@ -1905,8 +1862,8 @@ spec:
19051862
})
19061863

19071864
By("update GatewayProxy with new admin key")
1908-
updatedProxy := fmt.Sprintf(updatedGatewayProxy, s.Namespace(), s.Deployer.GetAdminEndpoint(resources.DataplaneService), resources.AdminAPIKey)
1909-
err = s.CreateResourceFromStringWithNamespace(updatedProxy, s.Namespace())
1865+
updatedProxy := fmt.Sprintf(updatedGatewayProxy, s.Deployer.GetAdminEndpoint(resources.DataplaneService), resources.AdminAPIKey)
1866+
err = s.CreateResourceFromString(updatedProxy)
19101867
Expect(err).NotTo(HaveOccurred(), "updating GatewayProxy")
19111868

19121869
By("verify HTTPRoute works for additional gateway group")
@@ -2060,7 +2017,7 @@ spec:
20602017
`
20612018
It("Should sync ApisixRoute during startup", func() {
20622019
By("apply ApisixRoute")
2063-
Expect(s.CreateResourceFromStringWithNamespace(route2, s.Namespace())).ShouldNot(HaveOccurred(), "applying HTTPRoute with non-existent parent")
2020+
Expect(s.CreateResourceFromString(route2)).ShouldNot(HaveOccurred(), "applying HTTPRoute with non-existent parent")
20642021
s.ResourceApplied("HTTPRoute", "httpbin", fmt.Sprintf(route, s.Namespace()), 1)
20652022

20662023
s.RequestAssert(&scaffold.RequestAssert{
@@ -2080,7 +2037,6 @@ spec:
20802037
Timeout: 30 * time.Second,
20812038
})
20822039

2083-
time.Sleep(8 * time.Second)
20842040
By("restart controller and dataplane")
20852041
s.Deployer.ScaleIngress(0)
20862042
s.Deployer.ScaleDataplane(0)
@@ -2093,7 +2049,7 @@ spec:
20932049
Host: "httpbin",
20942050
Check: scaffold.WithExpectedStatus(http.StatusOK),
20952051
Interval: time.Second * 2,
2096-
Timeout: 30 * time.Second,
2052+
Timeout: 1 * time.Minute,
20972053
})
20982054
s.RequestAssert(&scaffold.RequestAssert{
20992055
Method: "GET",

0 commit comments

Comments
 (0)