Skip to content

Commit a15337e

Browse files
committed
fix: test http route
Signed-off-by: ashing <[email protected]>
1 parent b031588 commit a15337e

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

test/e2e/gatewayapi/httproute.go

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,23 @@ import (
1616
var _ = Describe("Test HTTPRoute", func() {
1717
s := scaffold.NewDefaultScaffold()
1818

19+
var gatewayProxyYaml = `
20+
apiVersion: gateway.apisix.io/v1alpha1
21+
kind: GatewayProxy
22+
metadata:
23+
name: api7-proxy-config
24+
spec:
25+
provider:
26+
type: ControlPlane
27+
controlPlane:
28+
endpoints:
29+
- %s
30+
auth:
31+
type: AdminKey
32+
adminKey:
33+
value: "%s"
34+
`
35+
1936
var defautlGatewayClass = `
2037
apiVersion: gateway.networking.k8s.io/v1
2138
kind: GatewayClass
@@ -36,6 +53,11 @@ spec:
3653
- name: http1
3754
protocol: HTTP
3855
port: 80
56+
infrastructure:
57+
parametersRef:
58+
group: gateway.apisix.io
59+
kind: GatewayProxy
60+
name: api7-proxy-config
3961
`
4062
var defautlGatewayHTTPS = `
4163
apiVersion: gateway.networking.k8s.io/v1
@@ -54,6 +76,11 @@ spec:
5476
- kind: Secret
5577
group: ""
5678
name: test-apisix-tls
79+
infrastructure:
80+
parametersRef:
81+
group: gateway.apisix.io
82+
kind: GatewayProxy
83+
name: api7-proxy-config
5784
`
5885

5986
var ResourceApplied = func(resourType, resourceName, resourceRaw string, observedGeneration int) {
@@ -76,9 +103,15 @@ spec:
76103
}
77104

78105
var beforeEachHTTP = func() {
106+
By("create GatewayProxy")
107+
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
108+
err := s.CreateResourceFromString(gatewayProxy)
109+
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
110+
time.Sleep(5 * time.Second)
111+
79112
By("create GatewayClass")
80113
gatewayClassName := fmt.Sprintf("api7-%d", time.Now().Unix())
81-
err := s.CreateResourceFromStringWithNamespace(fmt.Sprintf(defautlGatewayClass, gatewayClassName, s.GetControllerName()), "")
114+
err = s.CreateResourceFromStringWithNamespace(fmt.Sprintf(defautlGatewayClass, gatewayClassName, s.GetControllerName()), "")
82115
Expect(err).NotTo(HaveOccurred(), "creating GatewayClass")
83116
time.Sleep(5 * time.Second)
84117

@@ -101,11 +134,17 @@ spec:
101134
}
102135

103136
var beforeEachHTTPS = func() {
137+
By("create GatewayProxy")
138+
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
139+
err := s.CreateResourceFromString(gatewayProxy)
140+
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
141+
time.Sleep(5 * time.Second)
142+
104143
secretName := _secretName
105144
createSecret(s, secretName)
106145
By("create GatewayClass")
107146
gatewayClassName := fmt.Sprintf("api7-%d", time.Now().Unix())
108-
err := s.CreateResourceFromStringWithNamespace(fmt.Sprintf(defautlGatewayClass, gatewayClassName, s.GetControllerName()), "")
147+
err = s.CreateResourceFromStringWithNamespace(fmt.Sprintf(defautlGatewayClass, gatewayClassName, s.GetControllerName()), "")
109148
Expect(err).NotTo(HaveOccurred(), "creating GatewayClass")
110149
time.Sleep(5 * time.Second)
111150

0 commit comments

Comments
 (0)