Skip to content

Commit d7ab910

Browse files
committed
fix: r
Signed-off-by: ashing <[email protected]>
1 parent 2010ba8 commit d7ab910

File tree

5 files changed

+31
-303
lines changed

5 files changed

+31
-303
lines changed

config/samples/config.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
log_level: "debug" # The log level of the API7 Ingress Controller.
1+
log_level: "info" # The log level of the API7 Ingress Controller.
22
# the default value is "info".
33

44
controller_name: gateway.api7.io/api7-ingress-controller # The controller name of the API7 Ingress Controller,
55
# which is used to identify the controller in the GatewayClass.
66
# The default value is "gateway.api7.io/api7-ingress-controller".
7-
87
leader_election_id: "api7-ingress-controller-leader" # The leader election ID for the API7 Ingress Controller.
98
# The default value is "api7-ingress-controller-leader".
10-
119
ingress_class: api7 # The ingress class name of the API7 Ingress Controller.
1210
ingress_publish_service: "" # The service name of the ingress publish service.
1311
ingress_status_address: [] # The status address of the ingress.
14-
1512
gateway_configs: # The configuration of the API7 Gateway.
1613
- name: api7 # The name of the Gateway in the Gateway API.
1714
control_plane:
18-
admin_key: "a7adm-2BU3prqKv68BU8DNTaZJIOnIhkH0RJ1xCY3tXGOiEneBfqVF5F-0a0f8eb4d7d94fc6aed43566a6f2989a" # The admin key of the control plane.
15+
admin_key: "${ADMIN_KEY}" # The admin key of the control plane.
1916
endpoints:
20-
- "https://172.18.0.5:7443" # The endpoint of the control plane.
17+
- ${ENDPOINT} # The endpoint of the control plane.
2118
tls_verify: false
2219
addresses: # record the status address of the gateway-api gateway
23-
- "172.18.0.5" # The LB IP of the gateway service.
20+
- "172.18.0.4" # The LB IP of the gateway service.

test/e2e/e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
_ "github.com/api7/api7-ingress-controller/test/e2e/adminapi"
2727
"github.com/api7/api7-ingress-controller/test/e2e/framework"
2828
_ "github.com/api7/api7-ingress-controller/test/e2e/gatewayapi"
29-
// _ "github.com/api7/api7-ingress-controller/test/e2e/ingress"
29+
_ "github.com/api7/api7-ingress-controller/test/e2e/ingress"
3030
)
3131

3232
// Run e2e tests using the Ginkgo runner.

test/e2e/gatewayapi/gateway.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package gatewayapi
33
import (
44
"context"
55
"fmt"
6+
"strings"
67
"time"
78

89
. "github.com/onsi/ginkgo/v2"
@@ -15,9 +16,9 @@ import (
1516

1617
const _secretName = "test-apisix-tls"
1718

18-
var Cert = framework.TestServerCert
19+
var Cert = strings.TrimSpace(framework.TestServerCert)
1920

20-
var Key = framework.TestServerKey
21+
var Key = strings.TrimSpace(framework.TestServerKey)
2122

2223
func createSecret(s *scaffold.Scaffold, secretName string) {
2324
err := s.NewKubeTlsSecret(secretName, Cert, Key)

test/e2e/ingress/ingress.go

Lines changed: 23 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ingress
33
import (
44
"context"
55
"fmt"
6+
"strings"
67
"time"
78

89
. "github.com/onsi/ginkgo/v2"
@@ -15,9 +16,9 @@ import (
1516

1617
const _secretName = "test-ingress-tls"
1718

18-
var Cert = framework.TestServerCert
19+
var Cert = strings.TrimSpace(framework.TestServerCert)
1920

20-
var Key = framework.TestServerKey
21+
var Key = strings.TrimSpace(framework.TestServerKey)
2122

2223
func createSecret(s *scaffold.Scaffold, secretName string) {
2324
err := s.NewKubeTlsSecret(secretName, Cert, Key)
@@ -54,7 +55,7 @@ spec:
5455
pathType: Prefix
5556
backend:
5657
service:
57-
name: example-service
58+
name: httpbin-service-e2e-test
5859
port:
5960
number: 80
6061
`
@@ -74,13 +75,20 @@ spec:
7475
ingressYaml, err := s.GetResourceYaml("Ingress", "api7-ingress")
7576
Expect(err).NotTo(HaveOccurred(), "getting Ingress yaml")
7677
Expect(ingressYaml).To(ContainSubstring("example.com"), "checking Ingress host")
78+
79+
By("verify HTTP request")
80+
s.NewAPISIXClient().
81+
GET("/get").
82+
WithHost("example.com").
83+
Expect().
84+
Status(200)
7785
})
7886
})
7987

8088
Context("Ingress TLS", func() {
8189
It("Check if SSL resource was created", func() {
8290
secretName := _secretName
83-
host := "secure.example.com"
91+
host := "api6.com"
8492
createSecret(s, secretName)
8593

8694
var defaultIngressClass = `
@@ -111,7 +119,7 @@ spec:
111119
pathType: Prefix
112120
backend:
113121
service:
114-
name: secure-service
122+
name: httpbin-service-e2e-test
115123
port:
116124
number: 80
117125
`, host, secretName, host)
@@ -129,87 +137,9 @@ spec:
129137
By("check TLS configuration")
130138
tls, err := s.DefaultDataplaneResource().SSL().List(context.Background())
131139
assert.Nil(GinkgoT(), err, "list tls error")
132-
assert.NotEmpty(GinkgoT(), tls, "tls list should not be empty")
133-
134-
// At least one TLS certificate should contain our host
135-
foundHost := false
136-
for _, sslObj := range tls {
137-
for _, sni := range sslObj.Snis {
138-
if sni == host {
139-
foundHost = true
140-
break
141-
}
142-
}
143-
if foundHost {
144-
break
145-
}
146-
}
147-
assert.True(GinkgoT(), foundHost, "host not found in any SSL configuration")
148-
})
149-
})
150-
151-
Context("Multiple Paths and Backends", func() {
152-
var defaultIngressClass = `
153-
apiVersion: networking.k8s.io/v1
154-
kind: IngressClass
155-
metadata:
156-
name: api7
157-
spec:
158-
controller: "gateway.api7.io/api7-ingress-controller"
159-
`
160-
161-
var multiPathIngress = `
162-
apiVersion: networking.k8s.io/v1
163-
kind: Ingress
164-
metadata:
165-
name: api7-ingress-multi
166-
spec:
167-
ingressClassName: api7
168-
rules:
169-
- host: multi.example.com
170-
http:
171-
paths:
172-
- path: /api
173-
pathType: Prefix
174-
backend:
175-
service:
176-
name: api-service
177-
port:
178-
number: 80
179-
- path: /web
180-
pathType: Prefix
181-
backend:
182-
service:
183-
name: web-service
184-
port:
185-
number: 80
186-
- path: /admin
187-
pathType: Prefix
188-
backend:
189-
service:
190-
name: admin-service
191-
port:
192-
number: 80
193-
`
194-
195-
It("Create Multi-path Ingress", func() {
196-
By("create IngressClass")
197-
err := s.CreateResourceFromStringWithNamespace(defaultIngressClass, "")
198-
Expect(err).NotTo(HaveOccurred(), "creating IngressClass")
199-
time.Sleep(5 * time.Second)
200-
201-
By("create Multi-path Ingress")
202-
err = s.CreateResourceFromString(multiPathIngress)
203-
Expect(err).NotTo(HaveOccurred(), "creating Multi-path Ingress")
204-
time.Sleep(5 * time.Second)
205-
206-
By("check Ingress status")
207-
ingressYaml, err := s.GetResourceYaml("Ingress", "api7-ingress-multi")
208-
Expect(err).NotTo(HaveOccurred(), "getting Ingress yaml")
209-
Expect(ingressYaml).To(ContainSubstring("multi.example.com"), "checking Ingress host")
210-
Expect(ingressYaml).To(ContainSubstring("/api"), "checking path /api")
211-
Expect(ingressYaml).To(ContainSubstring("/web"), "checking path /web")
212-
Expect(ingressYaml).To(ContainSubstring("/admin"), "checking path /admin")
140+
assert.Len(GinkgoT(), tls, 1, "tls number not expect")
141+
assert.Equal(GinkgoT(), Cert, tls[0].Cert, "tls cert not expect")
142+
assert.ElementsMatch(GinkgoT(), []string{host}, tls[0].Snis)
213143
})
214144
})
215145

@@ -225,15 +155,6 @@ spec:
225155
controller: "gateway.api7.io/api7-ingress-controller"
226156
`
227157

228-
var secondaryIngressClass = `
229-
apiVersion: networking.k8s.io/v1
230-
kind: IngressClass
231-
metadata:
232-
name: api7-secondary
233-
spec:
234-
controller: "gateway.api7.io/api7-ingress-controller"
235-
`
236-
237158
var defaultIngress = `
238159
apiVersion: networking.k8s.io/v1
239160
kind: Ingress
@@ -248,27 +169,7 @@ spec:
248169
pathType: Prefix
249170
backend:
250171
service:
251-
name: default-service
252-
port:
253-
number: 80
254-
`
255-
256-
var specificIngress = `
257-
apiVersion: networking.k8s.io/v1
258-
kind: Ingress
259-
metadata:
260-
name: api7-ingress-specific
261-
spec:
262-
ingressClassName: api7-secondary
263-
rules:
264-
- host: specific.example.com
265-
http:
266-
paths:
267-
- path: /
268-
pathType: Prefix
269-
backend:
270-
service:
271-
name: specific-service
172+
name: httpbin-service-e2e-test
272173
port:
273174
number: 80
274175
`
@@ -279,11 +180,6 @@ spec:
279180
Expect(err).NotTo(HaveOccurred(), "creating Default IngressClass")
280181
time.Sleep(5 * time.Second)
281182

282-
By("create Secondary IngressClass")
283-
err = s.CreateResourceFromStringWithNamespace(secondaryIngressClass, "")
284-
Expect(err).NotTo(HaveOccurred(), "creating Secondary IngressClass")
285-
time.Sleep(5 * time.Second)
286-
287183
By("create Ingress without IngressClass")
288184
err = s.CreateResourceFromString(defaultIngress)
289185
Expect(err).NotTo(HaveOccurred(), "creating Ingress without IngressClass")
@@ -294,16 +190,12 @@ spec:
294190
Expect(err).NotTo(HaveOccurred(), "getting Default Ingress yaml")
295191
Expect(ingressYaml).To(ContainSubstring("default.example.com"), "checking Default Ingress host")
296192

297-
By("create Ingress with specific IngressClass")
298-
err = s.CreateResourceFromString(specificIngress)
299-
Expect(err).NotTo(HaveOccurred(), "creating Ingress with specific IngressClass")
300-
time.Sleep(5 * time.Second)
301-
302-
By("check Specific Ingress")
303-
ingressYaml, err = s.GetResourceYaml("Ingress", "api7-ingress-specific")
304-
Expect(err).NotTo(HaveOccurred(), "getting Specific Ingress yaml")
305-
Expect(ingressYaml).To(ContainSubstring("specific.example.com"), "checking Specific Ingress host")
306-
Expect(ingressYaml).To(ContainSubstring("api7-secondary"), "checking Specific Ingress class")
193+
By("verify default ingress")
194+
s.NewAPISIXClient().
195+
GET("/get").
196+
WithHost("default.example.com").
197+
Expect().
198+
Status(200)
307199
})
308200
})
309201
})

0 commit comments

Comments
 (0)