Skip to content

Commit f8cd157

Browse files
author
Foo Bar
committed
v2
1 parent 59b3052 commit f8cd157

File tree

12 files changed

+81
-33
lines changed

12 files changed

+81
-33
lines changed

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ENVTEST_K8S_VERSION = 1.30.0
1212
KIND_NAME ?= api7-ingress-cluster
1313
GATEAY_API_VERSION ?= v1.1.0
1414

15-
DASHBOARD_VERSION ?= v3.2.14.6
15+
DASHBOARD_VERSION ?= dev
1616
TEST_TIMEOUT ?= 30m
1717

1818
# go
@@ -87,7 +87,7 @@ kind-e2e-test: kind-up build-image kind-load-images e2e-test
8787
# Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors.
8888
.PHONY: e2e-test
8989
e2e-test:
90-
DASHBOARD_VERSION=$(DASHBOARD_VERSION) go test ./test/e2e/ -test.timeout=$(TEST_TIMEOUT) -v -ginkgo.v
90+
DASHBOARD_VERSION=$(DASHBOARD_VERSION) go test ./test/e2e/ -test.timeout=$(TEST_TIMEOUT) -v -ginkgo.v -ginkgo.focus="$(TEST_FOCUS)"
9191

9292
.PHONY: conformance-test
9393
conformance-test:
@@ -131,6 +131,11 @@ pull-infra-images:
131131
@docker pull kennethreitz/httpbin:latest
132132
@docker pull jmalloc/echo-server:latest
133133

134+
135+
.PHONY: kind-load-image
136+
kind-load-image:
137+
@kind load docker-image $(IMG) --name $(KIND_NAME)
138+
134139
##@ Build
135140

136141
.PHONY: build

api/adc/types.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,10 @@ const (
461461

462462
// RewriteConfig is the rule config for proxy-rewrite plugin.
463463
type RewriteConfig struct {
464-
RewriteTarget string `json:"uri,omitempty"`
465-
RewriteTargetRegex []string `json:"regex_uri,omitempty"`
466-
Headers *Headers `json:"headers,omitempty"`
467-
Host string `json:"host,omitempty"`
464+
RewriteTarget string `json:"uri,omitempty" yaml:"uri,omitempty"`
465+
RewriteTargetRegex []string `json:"regex_uri,omitempty" yaml:"regex_uri,omitempty"`
466+
Headers *Headers `json:"headers,omitempty" yaml:"headers,omitempty"`
467+
Host string `json:"host,omitempty" yaml:"host,omitempty"`
468468
}
469469

470470
type Headers struct {
@@ -475,12 +475,12 @@ type Headers struct {
475475

476476
// ResponseRewriteConfig is the rule config for response-rewrite plugin.
477477
type ResponseRewriteConfig struct {
478-
StatusCode int `json:"status_code,omitempty"`
479-
Body string `json:"body,omitempty"`
480-
BodyBase64 bool `json:"body_base64,omitempty"`
481-
Headers *ResponseHeaders `json:"headers,omitempty"`
482-
LuaRestyExpr []expr.Expr `json:"vars,omitempty"`
483-
Filters []map[string]string `json:"filters,omitempty"`
478+
StatusCode int `json:"status_code,omitempty" yaml:"status_code,omitempty"`
479+
Body string `json:"body,omitempty" yaml:"body,omitempty"`
480+
BodyBase64 bool `json:"body_base64,omitempty" yaml:"body_base64,omitempty"`
481+
Headers *ResponseHeaders `json:"headers,omitempty" yaml:"headers,omitempty"`
482+
LuaRestyExpr []expr.Expr `json:"vars,omitempty" yaml:"vars,omitempty"`
483+
Filters []map[string]string `json:"filters,omitempty" yaml:"filters,omitempty"`
484484
}
485485

486486
type ResponseHeaders struct {
@@ -491,12 +491,12 @@ type ResponseHeaders struct {
491491

492492
// RequestMirror is the rule config for proxy-mirror plugin.
493493
type RequestMirror struct {
494-
Host string `json:"host"`
494+
Host string `json:"host" yaml:"host"`
495495
}
496496

497497
// RedirectConfig is the rule config for redirect plugin.
498498
type RedirectConfig struct {
499-
HttpToHttps bool `json:"http_to_https,omitempty"`
500-
URI string `json:"uri,omitempty"`
501-
RetCode int `json:"ret_code,omitempty"`
499+
HttpToHttps bool `json:"http_to_https,omitempty" yaml:"http_to_https,omitempty"`
500+
URI string `json:"uri,omitempty" yaml:"uri,omitempty"`
501+
RetCode int `json:"ret_code,omitempty" yaml:"ret_code,omitempty"`
502502
}

internal/provider/adc/adc.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ func (d *adcClient) sync(task Task) error {
8989
defer os.Remove(tmpFile.Name())
9090
defer tmpFile.Close()
9191

92-
log.Debugw("syncing resources", zap.String("file", tmpFile.Name()))
92+
log.Debugw("syncing resources", zap.String("file", tmpFile.Name()), zap.String("yaml", string(yaml)))
9393

9494
if _, err := tmpFile.Write(yaml); err != nil {
9595
return err
9696
}
9797
args := []string{
98-
"/app/adc/dist/apps/cli/main.js",
98+
"/workspace/api7/adc/dist/apps/cli/main.js",
9999
"sync",
100100
"-f", tmpFile.Name(),
101101
"--include-resource-type", "service",
@@ -116,7 +116,6 @@ func (d *adcClient) sync(task Task) error {
116116
"ADC_BACKEND=api7ee",
117117
"ADC_SERVER="+d.ServerAddr,
118118
"ADC_TOKEN="+d.Token,
119-
"ADC_GATEWAY_GROUP=default",
120119
)
121120

122121
if err := cmd.Run(); err != nil {

internal/provider/adc/translator/httproute.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package translator
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"strings"
67

@@ -53,10 +54,14 @@ func (t *Translator) fillPluginFromExtensionRef(plugins adctypes.Plugins, namesp
5354
}]
5455
for _, plugin := range pluginconfig.Spec.Plugins {
5556
pluginName := plugin.Name
56-
plugins[pluginName] = plugin.Config
57-
log.Errorw("plugin config", zap.String("namespace", namespace), zap.Any("plugin_config", plugin))
57+
var pluginconfig map[string]any
58+
if err := json.Unmarshal(plugin.Config.Raw, &pluginconfig); err != nil {
59+
log.Errorw("plugin config unmarshal failed", zap.Error(err))
60+
continue
61+
}
62+
plugins[pluginName] = pluginconfig
5863
}
59-
log.Errorw("plugin config", zap.String("namespace", namespace), zap.Any("plugins", plugins))
64+
log.Debugw("fill plugin from extension ref", zap.Any("plugins", plugins))
6065
}
6166
}
6267

test/conformance/suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestMain(m *testing.M) {
6767
AdminKey: adminKey,
6868
AdminTLSVerify: false,
6969
Namespace: namespace,
70-
AdminEnpoint: framework.DashboardTLSEndpoint + "/apisix/admin",
70+
AdminEnpoint: framework.DashboardTLSEndpoint,
7171
StatusAddress: address,
7272
})
7373

test/e2e/adminapi/dashboard_api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
v1 "github.com/api7/api7-ingress-controller/api/dashboard/v1"
2727
)
2828

29-
var _ = Describe("Test Dashboard admin-api sdk", func() {
29+
var _ = PDescribe("Test Dashboard admin-api sdk", func() {
3030
s := scaffold.NewDefaultScaffold()
3131

3232
Context("Service and Route", func() {

test/e2e/framework/dashboard.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,28 @@ postgresql:
212212
enabled: false
213213
developer_portal_configuration:
214214
enable: false
215+
dashboard_service:
216+
type: ClusterIP
217+
annotations: {}
218+
port: 7080
219+
tlsPort: 7443
220+
ingress:
221+
enabled: false
222+
className: ""
223+
annotations: {}
224+
# kubernetes.io/ingress.class: nginx
225+
# kubernetes.io/tls-acme: "true"
226+
hosts:
227+
- host: dashboard.local
228+
paths:
229+
- path: /
230+
pathType: ImplementationSpecific
231+
# backend:
232+
# service:
233+
# name: api7ee3-dashboard
234+
# port:
235+
# number: 7943
236+
tls: []
215237
`)
216238
if err != nil {
217239
panic(err)
@@ -372,6 +394,22 @@ func (s *Framework) GetAdminKey(gatewayGroupID string) string {
372394
return response.Value.Key
373395
}
374396

397+
func (s *Framework) GetToken(gatewayGroupID string) string {
398+
respExp := s.DashboardHTTPClient().PUT("/api/gateway_groups/"+gatewayGroupID+"/admin_key").
399+
WithHeader("Content-Type", "application/json").
400+
WithBasicAuth("admin", "admin").
401+
Expect()
402+
403+
respExp.Status(200).Body().Contains("key")
404+
405+
body := respExp.Body().Raw()
406+
407+
var response responseCreateGateway
408+
err := json.Unmarshal([]byte(body), &response)
409+
Expect(err).ToNot(HaveOccurred(), "unmarshal response")
410+
return response.Value.Key
411+
}
412+
375413
func (f *Framework) DeleteGatewayGroup(gatewayGroupID string) {
376414
respExp := f.DashboardHTTPClient().
377415
DELETE("/api/gateway_groups/"+gatewayGroupID).

test/e2e/framework/manifests/ingress.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,5 @@ spec:
383383
- name: ingress-config
384384
configMap:
385385
name: ingress-config
386-
securityContext:
387-
runAsNonRoot: true
388386
serviceAccountName: api7-ingress-controller-manager
389387
terminationGracePeriodSeconds: 10

test/e2e/gatewayapi/gateway.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ spec:
180180
})
181181
})
182182

183-
Context("Gateway SSL", func() {
183+
PContext("Gateway SSL", func() {
184184
It("Check if SSL resource was created", func() {
185185
secretName := _secretName
186186
host := "api6.com"
@@ -229,7 +229,7 @@ spec:
229229
assert.Equal(GinkgoT(), []string{host, "*.api6.com"}, tls[0].Snis)
230230
})
231231

232-
Context("Gateway SSL with and without hostname", func() {
232+
PContext("Gateway SSL with and without hostname", func() {
233233
It("Check if SSL resource was created", func() {
234234
secretName := _secretName
235235
createSecret(s, secretName)

test/e2e/gatewayapi/httproute.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ spec:
125125
Expect(gwyaml).To(ContainSubstring(`status: "True"`), "checking Gateway condition status")
126126
Expect(gwyaml).To(ContainSubstring("message: the gateway has been accepted by the api7-ingress-controller"), "checking Gateway condition message")
127127
}
128-
Context("HTTPRoute with HTTPS Gateway", func() {
128+
PContext("HTTPRoute with HTTPS Gateway", func() {
129129
var exactRouteByGet = `
130130
apiVersion: gateway.networking.k8s.io/v1
131131
kind: HTTPRoute

0 commit comments

Comments
 (0)