Skip to content

Commit

Permalink
Add automated tests for custom vs listeners (#4311)
Browse files Browse the repository at this point in the history
* Add automated tests for custom vs listeners

Signed-off-by: Haywood Shannon <[email protected]>
  • Loading branch information
haywoodsh authored Sep 5, 2023
1 parent 8e0b611 commit 94cd817
Show file tree
Hide file tree
Showing 18 changed files with 653 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ spec:
targetPort: 8443
protocol: TCP
name: custom-tls-port
- port: 8085
targetPort: 8085
protocol: TCP
name: custom-http
- port: 8445
targetPort: 8445
protocol: TCP
name: custom-https
- port: 9113
targetPort: 9113
protocol: TCP
Expand Down
8 changes: 8 additions & 0 deletions tests/data/common/service/nodeport-with-additional-ports.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,13 @@ spec:
targetPort: 8443
protocol: TCP
name: custom-ssl-port
- port: 8085
targetPort: 8085
protocol: TCP
name: custom-http
- port: 8445
targetPort: 8445
protocol: TCP
name: custom-https
selector:
app: nginx-ingress
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: k8s.nginx.org/v1alpha1
kind: GlobalConfiguration
metadata:
name: nginx-configuration
namespace: nginx-ingress
spec:
listeners:
- name: dns-udp
port: 5353
protocol: UDP
- name: dns-tcp
port: 5353
protocol: TCP
- name: http-8085
port: 8085
protocol: HTTP
ssl: true
- name: https-8445
port: 8445
protocol: HTTP
ssl: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: k8s.nginx.org/v1alpha1
kind: GlobalConfiguration
metadata:
name: nginx-configuration
namespace: nginx-ingress
spec:
listeners:
- name: dns-udp
port: 5353
protocol: UDP
- name: dns-tcp
port: 5353
protocol: TCP
- name: http-8085
port: 8085
protocol: HTTP
- name: https-8445
port: 8445
protocol: HTTP
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: k8s.nginx.org/v1alpha1
kind: GlobalConfiguration
metadata:
name: nginx-configuration
namespace: nginx-ingress
spec:
listeners:
- name: dns-udp
port: 5353
protocol: UDP
- name: dns-tcp
port: 5353
protocol: TCP
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: k8s.nginx.org/v1alpha1
kind: GlobalConfiguration
metadata:
name: nginx-configuration
namespace: nginx-ingress
spec:
listeners:
- name: dns-udp
port: 5353
protocol: UDP
- name: dns-tcp
port: 5353
protocol: TCP
- name: https-8445
port: 8445
protocol: HTTP
ssl: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: k8s.nginx.org/v1alpha1
kind: GlobalConfiguration
metadata:
name: nginx-configuration
namespace: nginx-ingress
spec:
listeners:
- name: dns-udp
port: 5353
protocol: UDP
- name: dns-tcp
port: 5353
protocol: TCP
- name: http-8085
port: 8085
protocol: HTTP
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: k8s.nginx.org/v1alpha1
kind: GlobalConfiguration
metadata:
name: nginx-configuration
namespace: nginx-ingress
spec:
listeners:
- name: dns-udp
port: 5353
protocol: UDP
- name: dns-tcp
port: 5353
protocol: TCP
- name: http-8085
port: 8085
protocol: HTTP
- name: https-8445
port: 8445
protocol: HTTP
ssl: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: virtual-server-status
spec:
host: virtual-server-status.example.com
tls:
secret: virtual-server-tls-secret
upstreams:
- name: backend2
service: backend2-svc
port: 80
- name: backend1
service: backend1-svc
port: 80
routes:
- path: /backend1
action:
pass: backend1
- path: /backend2
action:
pass: backend2
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: virtual-server-status
spec:
listener:
http: https-8445
https: http-8085
host: virtual-server-status.example.com
tls:
secret: virtual-server-tls-secret
upstreams:
- name: backend2
service: backend2-svc
port: 80
- name: backend1
service: backend1-svc
port: 80
routes:
- path: /backend1
action:
pass: backend1
- path: /backend2
action:
pass: backend2
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: virtual-server-status
spec:
listener:
http: ""
https: http-8085
host: virtual-server-status.example.com
tls:
secret: virtual-server-tls-secret
upstreams:
- name: backend2
service: backend2-svc
port: 80
- name: backend1
service: backend1-svc
port: 80
routes:
- path: /backend1
action:
pass: backend1
- path: /backend2
action:
pass: backend2
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: virtual-server-status
spec:
listener:
http: https-8445
https: ""
host: virtual-server-status.example.com
tls:
secret: virtual-server-tls-secret
upstreams:
- name: backend2
service: backend2-svc
port: 80
- name: backend1
service: backend1-svc
port: 80
routes:
- path: /backend1
action:
pass: backend1
- path: /backend2
action:
pass: backend2
25 changes: 25 additions & 0 deletions tests/data/virtual-server-custom-listeners/virtual-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: virtual-server-status
spec:
listener:
http: http-8085
https: https-8445
host: virtual-server-status.example.com
tls:
secret: virtual-server-tls-secret
upstreams:
- name: backend2
service: backend2-svc
port: 80
- name: backend1
service: backend1-svc
port: 80
routes:
- path: /backend1
action:
pass: backend1
- path: /backend2
action:
pass: backend2
8 changes: 8 additions & 0 deletions tests/suite/fixtures/custom_resource_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ def __init__(self, public_endpoint: PublicEndpoint, namespace, vs_host, vs_name,
self.backend_2_url = f"http://{public_endpoint.public_ip}:{public_endpoint.port}{vs_paths[1]}"
self.backend_1_url_ssl = f"https://{public_endpoint.public_ip}:{public_endpoint.port_ssl}{vs_paths[0]}"
self.backend_2_url_ssl = f"https://{public_endpoint.public_ip}:{public_endpoint.port_ssl}{vs_paths[1]}"
self.backend_1_url_custom = f"http://{public_endpoint.public_ip}:{public_endpoint.custom_http}{vs_paths[0]}"
self.backend_2_url_custom = f"http://{public_endpoint.public_ip}:{public_endpoint.custom_http}{vs_paths[1]}"
self.backend_1_url_custom_ssl = (
f"https://{public_endpoint.public_ip}:{public_endpoint.custom_https}{vs_paths[0]}"
)
self.backend_2_url_custom_ssl = (
f"https://{public_endpoint.public_ip}:{public_endpoint.custom_https}{vs_paths[1]}"
)
self.metrics_url = f"http://{public_endpoint.public_ip}:{public_endpoint.metrics_port}/metrics"


Expand Down
8 changes: 8 additions & 0 deletions tests/suite/fixtures/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def __init__(
udp_server_port=3334,
service_insight_port=9114,
custom_ssl_port=8443,
custom_http=8085,
custom_https=8445,
):
self.public_ip = public_ip
self.port = port
Expand All @@ -97,6 +99,8 @@ def __init__(
self.udp_server_port = udp_server_port
self.service_insight_port = service_insight_port
self.custom_ssl_port = custom_ssl_port
self.custom_http = custom_http
self.custom_https = custom_https


class IngressControllerPrerequisites:
Expand Down Expand Up @@ -185,6 +189,8 @@ def ingress_controller_endpoint(cli_arguments, kube_apis, ingress_controller_pre
udp_server_port,
service_insight_port,
custom_ssl_port,
custom_http,
custom_https,
) = get_service_node_ports(kube_apis.v1, service_name, namespace)
return PublicEndpoint(
public_ip,
Expand All @@ -196,6 +202,8 @@ def ingress_controller_endpoint(cli_arguments, kube_apis, ingress_controller_pre
udp_server_port,
service_insight_port,
custom_ssl_port,
custom_http,
custom_https,
)
else:
create_service_from_yaml(
Expand Down
Loading

0 comments on commit 94cd817

Please sign in to comment.