Skip to content

Commit ef43e0d

Browse files
authored
Merge pull request #25 from kgateway-dev/e2e
Adds Initial e2e Test Suite
2 parents bec38d0 + 333e6cd commit ef43e0d

18 files changed

Lines changed: 1501 additions & 14 deletions

File tree

Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,32 @@ help:
3838
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-17s\033[0m %s\n", $$1, $$2}'
3939

4040
.PHONY: all
41-
all: vet fmt verify test build;$(info $(M)...Begin to test, verify and build this project.) @ ## Test, verify and build this project.
41+
all: vet fmt verify build test-all;$(info $(M)...Begin to test, verify and build this project.) @ ## Test, verify and build this project.
4242

4343
# Run go fmt against code
4444
.PHONY: fmt
4545
fmt: ;$(info $(M)...Begin to run go fmt against code.) @ ## Run go fmt against code.
46-
gofmt -w ./pkg ./cmd
46+
gofmt -w ./pkg ./cmd ./test
4747

4848
# Run go vet against code
4949
.PHONY: vet
5050
vet: ;$(info $(M)...Begin to run go vet against code.) @ ## Run go vet against code.
51-
go vet ./pkg/... ./cmd/...
51+
go vet ./pkg/... ./cmd/... ./test/...
5252

53-
# Run go test against code
53+
# Run integration tests
5454
.PHONY: test
55-
test: vet;$(info $(M)...Begin to run tests.) @ ## Run tests.
55+
test: vet;$(info $(M)...Begin to run integration tests.) @ ## Run integration tests.
5656
go test -race -cover ./pkg/... ./cmd/...
5757

58+
# Run e2e tests
59+
.PHONY: test-e2e
60+
test-e2e: vet;$(info $(M)...Begin to run e2e tests.) @ ## Run e2e tests.
61+
go test -v ./test/e2e/...
62+
63+
# Run integration and e2e tests
64+
.PHONY: test-all
65+
test-all: test test-e2e;$(info $(M)...Completed test-all.) @ ## Run integration and e2e tests.
66+
5867
# Build the binary
5968
.PHONY: build
6069
build: vet;$(info $(M)...Build the binary.) @ ## Build the binary.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.25.3
44

55
require (
66
github.com/google/go-cmp v0.7.0
7-
github.com/kgateway-dev/kgateway/v2 v2.2.0-beta.1.0.20251203210329-f0eb663ac5bd
7+
github.com/kgateway-dev/kgateway/v2 v2.2.0-beta.3
88
github.com/olekukonko/tablewriter v0.0.5
99
github.com/samber/lo v1.39.0
1010
github.com/spf13/cobra v1.10.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm
5151
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
5252
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
5353
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
54-
github.com/kgateway-dev/kgateway/v2 v2.2.0-beta.1.0.20251203210329-f0eb663ac5bd h1:l6uyDclySJpQmXuT433sX/q1d1NpzYUCl6Nxbys5vGo=
55-
github.com/kgateway-dev/kgateway/v2 v2.2.0-beta.1.0.20251203210329-f0eb663ac5bd/go.mod h1:PTFdy5PWnh0b4FNvc4X93UkinNobzyct5oCtN6RNsV0=
54+
github.com/kgateway-dev/kgateway/v2 v2.2.0-beta.3 h1:+JISpfq0iPP1rWfLGBH+6b0GuWV7E1uJo6AR5uqE90U=
55+
github.com/kgateway-dev/kgateway/v2 v2.2.0-beta.3/go.mod h1:+WYYf8FRhr5YJ67+3DB0c3TzIntaGyLTtHQCVqzBkTk=
5656
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
5757
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
5858
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=

pkg/i2gw/implementations/kgateway/emitter.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -794,11 +794,13 @@ func applyAccessLogPolicy(
794794
Name: gwv1.ObjectName(gatewayName),
795795
},
796796
},
797-
AccessLog: []kgateway.AccessLog{
798-
{
799-
FileSink: &kgateway.FileSink{
800-
Path: "/dev/stdout",
801-
StringFormat: ptr.To(`[%START_TIME%] "%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% "%REQ(X-FORWARDED-FOR)%" "%REQ(USER-AGENT)%" "%REQ(X-REQUEST-ID)%" "%REQ(:AUTHORITY)%" "%UPSTREAM_HOST%"%n`),
797+
HTTPSettings: kgateway.HTTPSettings{
798+
AccessLog: []kgateway.AccessLog{
799+
{
800+
FileSink: &kgateway.FileSink{
801+
Path: "/dev/stdout",
802+
StringFormat: ptr.To(`[%START_TIME%] "%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% "%REQ(X-FORWARDED-FOR)%" "%REQ(USER-AGENT)%" "%REQ(X-REQUEST-ID)%" "%REQ(:AUTHORITY)%" "%UPSTREAM_HOST%"%n`),
803+
},
802804
},
803805
},
804806
},

pkg/i2gw/implementations/kgateway/emitter_integration_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,15 @@ func TestKgatewayIngressNginxIntegration_Golden(t *testing.T) {
198198
"pkg", "i2gw", "implementations", "kgateway", "testing", "testdata", "output", "golden.yaml",
199199
),
200200
},
201+
{
202+
name: "basic_features",
203+
inputRel: filepath.Join(
204+
"pkg", "i2gw", "implementations", "kgateway", "testing", "testdata", "input", "basic.yaml",
205+
),
206+
goldenRel: filepath.Join(
207+
"pkg", "i2gw", "implementations", "kgateway", "testing", "testdata", "output", "basic.yaml",
208+
),
209+
},
201210
{
202211
name: "cors",
203212
inputRel: filepath.Join(
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
annotations:
5+
ingress2gateway.kubernetes.io/implementation: kgateway
6+
name: demo-localhost
7+
spec:
8+
ingressClassName: nginx
9+
rules:
10+
- host: demo.localdev.me
11+
http:
12+
paths:
13+
- backend:
14+
service:
15+
name: echo-backend
16+
port:
17+
number: 8080
18+
path: /
19+
pathType: Prefix
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: Gateway
3+
metadata:
4+
annotations:
5+
gateway.networking.k8s.io/generator: ingress2gateway-dev
6+
name: nginx
7+
spec:
8+
gatewayClassName: kgateway
9+
listeners:
10+
- hostname: demo.localdev.me
11+
name: demo-localdev-me-http
12+
port: 80
13+
protocol: HTTP
14+
status: {}
15+
---
16+
apiVersion: gateway.networking.k8s.io/v1
17+
kind: HTTPRoute
18+
metadata:
19+
annotations:
20+
gateway.networking.k8s.io/generator: ingress2gateway-dev
21+
name: demo-localhost-demo-localdev-me
22+
spec:
23+
hostnames:
24+
- demo.localdev.me
25+
parentRefs:
26+
- name: nginx
27+
rules:
28+
- backendRefs:
29+
- name: echo-backend
30+
port: 8080
31+
matches:
32+
- path:
33+
type: PathPrefix
34+
value: /
35+
status:
36+
parents: []

pkg/i2gw/providers/ingressnginx/validation.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import (
2727
// (cookie paths do not support regex).
2828
//
2929
// **Note:** This validation should be in IR package but keeping separate to avoid
30-
// polluting core IR package with downstream logic.
30+
//
31+
// polluting core IR package with downstream logic.
3132
func validateRegexCookiePath(ir *intermediate.IR) field.ErrorList {
3233
var errs field.ErrorList
3334

0 commit comments

Comments
 (0)