Skip to content

Commit adad8ad

Browse files
authored
feat: support conformance test (#47)
1 parent 6b3dc18 commit adad8ad

40 files changed

+1614
-586
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Conformance Test
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- release-v2-dev
8+
pull_request:
9+
branches:
10+
- master
11+
- release-v2-dev
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
prepare:
19+
name: Prepare
20+
runs-on: buildjet-2vcpu-ubuntu-2204
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Go Env
26+
id: go
27+
uses: actions/setup-go@v4
28+
with:
29+
go-version: "1.22"
30+
31+
- name: Install kind
32+
run: |
33+
go install sigs.k8s.io/[email protected]
34+
35+
e2e-test:
36+
needs:
37+
- prepare
38+
runs-on: buildjet-2vcpu-ubuntu-2204
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
with:
43+
submodules: recursive
44+
45+
- name: Setup Go Env
46+
uses: actions/setup-go@v4
47+
with:
48+
go-version: "1.22"
49+
50+
- name: Login to Private Registry
51+
uses: docker/login-action@v1
52+
with:
53+
registry: hkccr.ccs.tencentyun.com
54+
username: ${{ secrets.PRIVATE_DOCKER_USERNAME }}
55+
password: ${{ secrets.PRIVATE_DOCKER_PASSWORD }}
56+
57+
- name: Build images
58+
env:
59+
TAG: dev
60+
ARCH: amd64
61+
ENABLE_PROXY: "false"
62+
BASE_IMAGE_TAG: "debug"
63+
run: |
64+
echo "building images..."
65+
make build-image
66+
67+
- name: Launch Kind Cluster
68+
run: |
69+
make kind-up
70+
71+
- name: Install And Run Cloud Provider KIND
72+
run: |
73+
go install sigs.k8s.io/cloud-provider-kind@latest
74+
nohup cloud-provider-kind > /tmp/kind-loadbalancer.log 2>&1 &
75+
76+
- name: Install Gateway API
77+
run: |
78+
make install-gateway-api
79+
80+
- name: Loading Docker Image to Kind Cluster
81+
run: |
82+
make kind-load-images
83+
84+
- name: Run Conformance Test
85+
shell: bash
86+
env:
87+
API7_EE_LICENSE: ${{ secrets.API7_EE_LICENSE }}
88+
run: |
89+
make conformance-test
90+
91+
- name: Upload Gateway API Conformance Report
92+
uses: actions/upload-artifact@v2
93+
with:
94+
name: api7-ingress-controller-conformance-report.yaml
95+
path: api7-ingress-controller-conformance-report.yaml

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ go.work
2929
dist
3030
.tmp
3131
api7-ingress-controller
32+
api7-ingress-controller-conformance-report.yaml

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ FROM gcr.io/distroless/static-debian12:${BASE_IMAGE_TAG}
1616
WORKDIR /app
1717

1818
COPY --from=builder /bin/api7-ingress-controller .
19-
COPY conf/config.yaml ./conf/config.yaml
19+
COPY config/samples/config.yaml ./conf/config.yaml
2020

2121
ENTRYPOINT ["/app/api7-ingress-controller"]
2222
CMD ["-c", "/app/conf/config.yaml"]

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ vet: ## Run go vet against code.
7878

7979
.PHONY: test
8080
test: manifests generate fmt vet envtest ## Run tests.
81-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out
81+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e | grep -v /conformance) -coverprofile cover.out
8282

8383
.PHONY: kind-e2e-test
8484
kind-e2e-test: kind-up build-image kind-load-images e2e-test
@@ -88,6 +88,10 @@ kind-e2e-test: kind-up build-image kind-load-images e2e-test
8888
e2e-test:
8989
DASHBOARD_VERSION=$(DASHBOARD_VERSION) go test ./test/e2e/ -v -ginkgo.v
9090

91+
.PHONY: conformance-test
92+
conformance-test:
93+
DASHBOARD_VERSION=v3.2.14.2 go test -v ./test/conformance -tags=conformance
94+
9195
.PHONY: lint
9296
lint: golangci-lint ## Run golangci-lint linter
9397
$(GOLANGCI_LINT) run
@@ -184,6 +188,10 @@ endif
184188
install-gateway-api: ## Install Gateway API CRDs into the K8s cluster specified in ~/.kube/config.
185189
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/$(GATEAY_API_VERSION)/standard-install.yaml
186190

191+
.PHONY: uninstall-gateway-api
192+
uninstall-gateway-api: ## Uninstall Gateway API CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
193+
kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/$(GATEAY_API_VERSION)/standard-install.yaml
194+
187195
.PHONY: install
188196
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
189197
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -

cmd/root/root.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,26 @@ import (
4040
"github.com/api7/gopkg/pkg/log"
4141
)
4242

43-
type ControlPlanesFlag struct {
44-
ControlPlanes []*config.ControlPlaneConfig
43+
type GatewayConfigsFlag struct {
44+
GatewayConfigs []*config.GatewayConfig
4545
}
4646

47-
func (f *ControlPlanesFlag) String() string {
48-
data, _ := yaml.Marshal(f.ControlPlanes)
47+
func (f *GatewayConfigsFlag) String() string {
48+
data, _ := yaml.Marshal(f.GatewayConfigs)
4949
return string(data)
5050
}
5151

52-
func (f *ControlPlanesFlag) Set(value string) error {
53-
var controlPlanes []*config.ControlPlaneConfig
54-
if err := yaml.Unmarshal([]byte(value), &controlPlanes); err != nil {
52+
func (f *GatewayConfigsFlag) Set(value string) error {
53+
var gatewayConfigs []*config.GatewayConfig
54+
if err := yaml.Unmarshal([]byte(value), &gatewayConfigs); err != nil {
5555
return err
5656
}
57-
f.ControlPlanes = controlPlanes
57+
f.GatewayConfigs = gatewayConfigs
5858
return nil
5959
}
6060

61-
func (f *ControlPlanesFlag) Type() string {
62-
return "controlPlanes"
61+
func (f *GatewayConfigsFlag) Type() string {
62+
return "gateway_configs"
6363
}
6464

6565
func NewRootCmd() *cobra.Command {
@@ -91,7 +91,7 @@ func newAPI7IngressController() *cobra.Command {
9191
cfg := config.ControllerConfig
9292
var configPath string
9393

94-
var controlPlanesFlag ControlPlanesFlag
94+
var controlPlanesFlag GatewayConfigsFlag
9595
cmd := &cobra.Command{
9696
Use: "api7-ingress-controller [command]",
9797
Long: "Yet another Ingress controller for Kubernetes using api7ee Gateway as the high performance reverse proxy.",
@@ -105,7 +105,7 @@ func newAPI7IngressController() *cobra.Command {
105105
cfg = c
106106
config.SetControllerConfig(c)
107107
} else {
108-
cfg.ControlPlanes = controlPlanesFlag.ControlPlanes
108+
cfg.GatewayConfigs = controlPlanesFlag.GatewayConfigs
109109
}
110110

111111
if err := cfg.Validate(); err != nil {

conf/config.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

config/default/kustomization.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ resources:
2727
#- ../prometheus
2828
# [METRICS] Expose the controller manager metrics service.
2929
- metrics_service.yaml
30+
- ../samples
3031

3132
# Uncomment the patches line if you enable Metrics, and/or are using webhooks and cert-manager
32-
patches:
33+
#patches:
3334
# [METRICS] The following patch will enable the metrics endpoint using HTTPS and the port :8443.
3435
# More info: https://book.kubebuilder.io/reference/metrics
35-
- path: manager_patch.yaml
36-
target:
37-
kind: Deployment
36+
#- path: manager_patch.yaml
37+
# target:
38+
# kind: Deployment
3839

3940
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
4041
# crd/kustomization.yaml

config/default/manager_patch.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

config/manager/manager.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,12 @@ spec:
5858
# seccompProfile:
5959
# type: RuntimeDefault
6060
containers:
61-
- command:
62-
- /manager
63-
args:
64-
- --leader-elect
65-
- --health-probe-bind-address=:8081
66-
image: controller:latest
61+
- image: controller:latest
6762
name: manager
63+
volumeMounts:
64+
- name: config-volume
65+
mountPath: /app/conf/config.yaml
66+
subPath: config.yaml
6867
securityContext:
6968
allowPrivilegeEscalation: false
7069
capabilities:
@@ -91,5 +90,9 @@ spec:
9190
requests:
9291
cpu: 10m
9392
memory: 64Mi
93+
volumes:
94+
- name: config-volume
95+
configMap:
96+
name: controller-config
9497
serviceAccountName: controller-manager
9598
terminationGracePeriodSeconds: 10

config/rbac/role.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ rules:
1111
verbs:
1212
- create
1313
- patch
14+
- apiGroups:
15+
- ""
16+
resources:
17+
- namespaces
18+
verbs:
19+
- get
20+
- list
21+
- watch
22+
- apiGroups:
23+
- ""
24+
resources:
25+
- secrets
26+
verbs:
27+
- get
28+
- list
29+
- watch
1430
- apiGroups:
1531
- ""
1632
resources:

0 commit comments

Comments
 (0)