-
Notifications
You must be signed in to change notification settings - Fork 126
Functional Tests for SnippetsFilter #2664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: coffee | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: coffee | ||
template: | ||
metadata: | ||
labels: | ||
app: coffee | ||
spec: | ||
containers: | ||
- name: coffee | ||
image: nginxdemos/nginx-hello:plain-text | ||
ports: | ||
- containerPort: 8080 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: coffee | ||
spec: | ||
ports: | ||
- port: 80 | ||
targetPort: 8080 | ||
protocol: TCP | ||
name: http | ||
selector: | ||
app: coffee | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: tea | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: tea | ||
template: | ||
metadata: | ||
labels: | ||
app: tea | ||
spec: | ||
containers: | ||
- name: tea | ||
image: nginxdemos/nginx-hello:plain-text | ||
ports: | ||
- containerPort: 8080 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: tea | ||
spec: | ||
ports: | ||
- port: 80 | ||
targetPort: 8080 | ||
protocol: TCP | ||
name: http | ||
selector: | ||
app: tea | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: soda | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: soda | ||
template: | ||
metadata: | ||
labels: | ||
app: soda | ||
spec: | ||
containers: | ||
- name: soda | ||
image: nginxdemos/nginx-hello:plain-text | ||
ports: | ||
- containerPort: 8080 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: soda | ||
spec: | ||
ports: | ||
- port: 80 | ||
targetPort: 8080 | ||
protocol: TCP | ||
name: http | ||
selector: | ||
app: soda |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
name: gateway | ||
spec: | ||
gatewayClassName: nginx | ||
listeners: | ||
- name: http | ||
port: 80 | ||
protocol: HTTP | ||
hostname: "*.example.com" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: grpc-backend | ||
spec: | ||
selector: | ||
app: grpc-backend | ||
ports: | ||
- protocol: TCP | ||
port: 8080 | ||
targetPort: 50051 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: grpc-backend | ||
labels: | ||
app: grpc-backend | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: grpc-backend | ||
template: | ||
metadata: | ||
labels: | ||
app: grpc-backend | ||
spec: | ||
containers: | ||
- name: grpc-backend | ||
image: ghcr.io/nginxinc/kic-test-grpc-server:0.2.2 | ||
env: | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
resources: | ||
requests: | ||
cpu: 10m |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apiVersion: gateway.nginx.org/v1alpha1 | ||
kind: SnippetsFilter | ||
metadata: | ||
name: invalid-context | ||
spec: | ||
snippets: | ||
- context: http | ||
value: aio on; | ||
- context: http.server | ||
value: worker_priority 0; # wrong context for the directive, should be main. | ||
- context: http.server.location | ||
value: keepalive_time 10s; | ||
--- | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: soda | ||
spec: | ||
parentRefs: | ||
- name: gateway | ||
sectionName: http | ||
hostnames: | ||
- "cafe.example.com" | ||
rules: | ||
- matches: | ||
- path: | ||
type: Exact | ||
value: /soda | ||
filters: | ||
- type: ExtensionRef | ||
extensionRef: | ||
group: gateway.nginx.org | ||
kind: SnippetsFilter | ||
name: invalid-context | ||
backendRefs: | ||
- name: soda | ||
port: 80 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
apiVersion: gateway.nginx.org/v1alpha1 | ||
kind: SnippetsFilter | ||
metadata: | ||
name: duplicate-directive | ||
spec: | ||
snippets: | ||
- context: main | ||
value: worker_processes auto; # already present in the configuration | ||
- context: http | ||
value: aio on; | ||
- context: http.server | ||
value: auth_delay 10s; | ||
- context: http.server.location | ||
value: keepalive_time 10s; | ||
--- | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: tea | ||
spec: | ||
parentRefs: | ||
- name: gateway | ||
Check failure on line 22 in tests/suite/manifests/snippets-filter/invalid-duplicate-sf.yaml
|
||
sectionName: http | ||
hostnames: | ||
- "cafe.example.com" | ||
Check failure on line 25 in tests/suite/manifests/snippets-filter/invalid-duplicate-sf.yaml
|
||
rules: | ||
- matches: | ||
Check failure on line 27 in tests/suite/manifests/snippets-filter/invalid-duplicate-sf.yaml
|
||
- path: | ||
Check failure on line 28 in tests/suite/manifests/snippets-filter/invalid-duplicate-sf.yaml
|
||
type: Exact | ||
value: /tea | ||
filters: | ||
- type: ExtensionRef | ||
extensionRef: | ||
group: gateway.nginx.org | ||
kind: SnippetsFilter | ||
name: duplicate-directive | ||
backendRefs: | ||
- name: tea | ||
Check failure on line 38 in tests/suite/manifests/snippets-filter/invalid-duplicate-sf.yaml
|
||
port: 80 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
apiVersion: gateway.nginx.org/v1alpha1 | ||
kind: SnippetsFilter | ||
metadata: | ||
name: all-contexts | ||
spec: | ||
snippets: | ||
- context: main | ||
value: worker_priority 0; | ||
- context: http | ||
value: aio on; | ||
- context: http.server | ||
value: auth_delay 10s; | ||
- context: http.server.location | ||
value: keepalive_time 10s; | ||
--- | ||
apiVersion: gateway.nginx.org/v1alpha1 | ||
kind: SnippetsFilter | ||
metadata: | ||
name: grpc-all-contexts | ||
spec: | ||
snippets: | ||
- context: main | ||
value: worker_shutdown_timeout 120s; | ||
- context: http | ||
value: types_hash_bucket_size 64; | ||
- context: http.server | ||
value: server_tokens on; | ||
- context: http.server.location | ||
value: tcp_nodelay on; | ||
--- | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: coffee | ||
spec: | ||
parentRefs: | ||
- name: gateway | ||
sectionName: http | ||
hostnames: | ||
- "cafe.example.com" | ||
rules: | ||
- matches: | ||
- path: | ||
type: PathPrefix | ||
value: /coffee | ||
filters: | ||
- type: ExtensionRef | ||
extensionRef: | ||
group: gateway.nginx.org | ||
kind: SnippetsFilter | ||
name: all-contexts | ||
backendRefs: | ||
- name: coffee | ||
port: 80 | ||
--- | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: GRPCRoute | ||
metadata: | ||
name: grpc-route | ||
spec: | ||
parentRefs: | ||
- name: gateway | ||
sectionName: http | ||
rules: | ||
- matches: | ||
- method: | ||
service: helloworld.Greeter | ||
method: SayHello | ||
filters: | ||
- type: ExtensionRef | ||
extensionRef: | ||
group: gateway.nginx.org | ||
kind: SnippetsFilter | ||
name: grpc-all-contexts | ||
backendRefs: | ||
- name: grpc-backend | ||
port: 8080 |
Uh oh!
There was an error while loading. Please reload this page.