-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
275 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: backend | ||
spec: | ||
replicas: 2 | ||
selector: | ||
matchLabels: | ||
app: backend | ||
template: | ||
metadata: | ||
labels: | ||
app: backend | ||
spec: | ||
containers: | ||
- name: backend | ||
image: nginxdemos/nginx-hello:plain-text | ||
ports: | ||
- containerPort: 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: ingress | ||
spec: | ||
ingressClassName: nginx | ||
tls: | ||
- hosts: | ||
- cafe.example.com | ||
secretName: secret | ||
rules: | ||
- host: cafe.example.com | ||
http: | ||
paths: | ||
- path: /backend | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: backend-svc | ||
port: | ||
number: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: ns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: test-secret | ||
type: kubernetes.io/tls | ||
data: | ||
tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUQ4RENDQXRpZ0F3SUJBZ0lKQU9jbHdCelprYmlhTUEwR0NTcUdTSWIzRFFFQkJRVUFNRmd4Q3pBSkJnTlYKQkFZVEFsVlRNUXN3Q1FZRFZRUUlFd0pEUVRFaE1COEdBMVVFQ2hNWVNXNTBaWEp1WlhRZ1YybGtaMmwwY3lCUQpkSGtnVEhSa01Sa3dGd1lEVlFRREV4QmpZV1psTG1WNFlXMXdiR1V1WTI5dE1CNFhEVEUzTURnek1URXdNVGN5Ck1Gb1hEVEU0TURnek1URXdNVGN5TUZvd1dERUxNQWtHQTFVRUJoTUNWVk14Q3pBSkJnTlZCQWdUQWtOQk1TRXcKSHdZRFZRUUtFeGhKYm5SbGNtNWxkQ0JYYVdSbmFYUnpJRkIwZVNCTWRHUXhHVEFYQmdOVkJBTVRFR05oWm1VdQpaWGhoYlhCc1pTNWpiMjB3Z2dFaU1BMEdDU3FHU0liM0RRRUJBUVVBQTRJQkR3QXdnZ0VLQW9JQkFRQzdIT0xJCm5oZjE1aUcxOE16RXBzN0lvZmxHQmovMi9NVjA0OWtBS0hrTnZOem1XaXRXWDV2QU1yRkF5THY0dXBIWDI5b0IKa3l6YUhlYyt2TlFibEh1bStINUtkUWZXWHFXNkJ6UnVhMzBreEkrcG91cnhpNy9jaDJORS92djBhRGtvaTJ0RAovOUI2aHAyVkoxWXFJdm9hQ2wwSmFYWDd0WEc4SGU1S1BSZzBYMm1Mblcwa29tay9ZVGRPbS9xOVRjUDRnUmhrCms3bUhJMDlSME5vN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SZzd1Z093L2NiZWdLVklZY3hTdXdRKzYrNUZYOApKRzlhbGxzdXovTk40b2RpMzRvblpEVmRZcURnY2xaZnZucXZKMHZWSzc1VXhQZ3F3aUJQCi0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: backend-svc | ||
spec: | ||
ports: | ||
- port: 80 | ||
targetPort: 8080 | ||
protocol: TCP | ||
name: http | ||
selector: | ||
app: backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: tcp | ||
spec: | ||
replicas: 2 | ||
selector: | ||
matchLabels: | ||
app: tcp | ||
template: | ||
metadata: | ||
labels: | ||
app: tcp | ||
spec: | ||
containers: | ||
- name: tcp-service | ||
image: ghcr.io/nginxinc/kic-test-tcp-server:0.2.1 | ||
ports: | ||
- containerPort: 3333 | ||
name: tcp-server | ||
protocol: TCP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: k8s.nginx.org/v1 | ||
kind: TransportServer | ||
metadata: | ||
name: transport-server | ||
spec: | ||
listener: | ||
name: tcp-server | ||
protocol: TCP | ||
upstreams: | ||
- name: tcp-app | ||
service: tcp-service | ||
port: 3333 | ||
action: | ||
pass: tcp-app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: k8s.nginx.org/v1 | ||
kind: VirtualServer | ||
metadata: | ||
name: vs | ||
spec: | ||
host: vs.example.com | ||
tls: | ||
secret: secret | ||
upstreams: | ||
- name: backend | ||
service: backend-svc | ||
port: 80 | ||
routes: | ||
- path: "/backend" | ||
action: | ||
pass: backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import os | ||
import tempfile | ||
|
||
import pytest | ||
import yaml | ||
from settings import DEPLOYMENTS, TEST_DATA | ||
from suite.utils.custom_resources_utils import create_resource_from_manifest, read_custom_resource | ||
from suite.utils.resources_utils import ( | ||
create_ingress, | ||
create_items_from_yaml, | ||
create_namespace, | ||
delete_namespace, | ||
wait_before_test, | ||
) | ||
from suite.utils.vs_vsr_resources_utils import create_virtual_server | ||
|
||
tcp_deployment = f"{TEST_DATA}/upgrade-test-resources/tcp-deployment.yaml" | ||
deployment = f"{TEST_DATA}/upgrade-test-resources/deployment.yaml" | ||
service = f"{TEST_DATA}/upgrade-test-resources/service.yaml" | ||
ns = f"{TEST_DATA}/upgrade-test-resources/ns.yaml" | ||
ingress = f"{TEST_DATA}/upgrade-test-resources/ingress.yaml" | ||
vs = f"{TEST_DATA}/upgrade-test-resources/virtual-server.yaml" | ||
ts = f"{TEST_DATA}/upgrade-test-resources/transport-server.yaml" | ||
secret = f"{TEST_DATA}/upgrade-test-resources/secret.yaml" | ||
|
||
# Below test class only deployes resources for upgrade testing, IC deployment should be done manually via helm. | ||
|
||
|
||
class TestUpgrade: | ||
@pytest.mark.create | ||
def test_create(self, request, kube_apis): | ||
count = int(request.config.getoption("--num")) | ||
|
||
for i in range(1, count + 1): | ||
with open(ns) as f: | ||
doc = yaml.safe_load(f) | ||
doc["metadata"]["name"] = f"ns-{i}" | ||
with tempfile.NamedTemporaryFile(mode="w+", suffix=".yml", delete=False) as temp: | ||
temp.write(yaml.safe_dump(doc) + "---\n") | ||
namespace = create_namespace(kube_apis.v1, doc) | ||
os.remove(temp.name) | ||
|
||
with open(deployment) as f: | ||
doc = yaml.safe_load(f) | ||
doc["metadata"]["name"] = f"backend-{i}" | ||
doc["spec"]["selector"]["matchLabels"]["app"] = f"backend-{i}" | ||
doc["spec"]["template"]["metadata"]["labels"]["app"] = f"backend-{i}" | ||
doc["metadata"]["name"] = f"backend-{i}" | ||
with tempfile.NamedTemporaryFile(mode="w+", suffix=".yml", delete=False) as temp: | ||
temp.write(yaml.safe_dump(doc) + "---\n") | ||
create_items_from_yaml(kube_apis, temp.name, namespace) | ||
os.remove(temp.name) | ||
|
||
with open(service) as f: | ||
doc = yaml.safe_load(f) | ||
doc["metadata"]["name"] = f"backend-svc-{i}" | ||
doc["spec"]["selector"]["app"] = f"backend-{i}" | ||
with tempfile.NamedTemporaryFile(mode="w+", suffix=".yml", delete=False) as temp: | ||
temp.write(yaml.safe_dump(doc) + "---\n") | ||
create_items_from_yaml(kube_apis, temp.name, namespace) | ||
os.remove(temp.name) | ||
|
||
with open(secret) as f: | ||
doc = yaml.safe_load(f) | ||
doc["metadata"]["name"] = f"secret-{i}" | ||
with tempfile.NamedTemporaryFile(mode="w+", suffix=".yml", delete=False) as temp: | ||
temp.write(yaml.safe_dump(doc) + "---\n") | ||
create_items_from_yaml(kube_apis, temp.name, namespace) | ||
os.remove(temp.name) | ||
|
||
# VirtualServer | ||
with open(vs) as f: | ||
doc = yaml.safe_load(f) | ||
doc["metadata"]["name"] = f"vs-{i}" | ||
doc["spec"]["host"] = f"vs-{i}.example.com" | ||
doc["spec"]["tls"]["secret"] = f"secret-{i}" | ||
doc["spec"]["upstreams"][0]["name"] = f"backend-{i}" | ||
doc["spec"]["upstreams"][0]["service"] = f"backend-svc-{i}" | ||
doc["spec"]["routes"][0]["action"]["pass"] = f"backend-{i}" | ||
create_virtual_server(kube_apis.custom_objects, doc, namespace) | ||
|
||
# Ingress | ||
with open(ingress) as f: | ||
doc = yaml.safe_load(f) | ||
doc["metadata"]["name"] = f"ingress-{i}" | ||
doc["spec"]["tls"][0]["hosts"][0] = f"ingress-{i}.example.com" | ||
doc["spec"]["tls"][0]["secretName"] = f"secret-{i}" | ||
doc["spec"]["rules"][0]["host"] = f"ingress-{i}.example.com" | ||
doc["spec"]["rules"][0]["http"]["paths"][0]["path"] = f"/backend-{i}" | ||
doc["spec"]["rules"][0]["http"]["paths"][0]["backend"]["service"]["name"] = f"backend-svc-{i}" | ||
create_ingress(kube_apis.networking_v1, namespace, doc) | ||
|
||
# TransportServer | ||
with open(tcp_deployment) as f: | ||
doc = yaml.safe_load(f) | ||
doc["metadata"]["name"] = f"tcp-{i}" | ||
doc["spec"]["selector"]["matchLabels"]["app"] = f"tcp-{i}" | ||
doc["spec"]["template"]["metadata"]["labels"]["app"] = f"tcp-{i}" | ||
with tempfile.NamedTemporaryFile(mode="w+", suffix=".yml", delete=False) as temp: | ||
temp.write(yaml.safe_dump(doc) + "---\n") | ||
create_items_from_yaml(kube_apis, temp.name, namespace) | ||
os.remove(temp.name) | ||
|
||
with open(service) as f: | ||
doc = yaml.safe_load(f) | ||
doc["metadata"]["name"] = f"tcp-svc-{i}" | ||
doc["spec"]["selector"]["app"] = f"tcp-{i}" | ||
with tempfile.NamedTemporaryFile(mode="w+", suffix=".yml", delete=False) as temp: | ||
temp.write(yaml.safe_dump(doc) + "---\n") | ||
create_items_from_yaml(kube_apis, temp.name, namespace) | ||
os.remove(temp.name) | ||
|
||
with open(ts) as f: | ||
doc = yaml.safe_load(f) | ||
doc["metadata"]["name"] = f"ts-{i}" | ||
doc["spec"]["listener"]["name"] = "dns-tcp" | ||
doc["spec"]["upstreams"][0]["name"] = f"tcp-{i}" | ||
doc["spec"]["upstreams"][0]["service"] = f"tcp-svc-{i}" | ||
doc["spec"]["upstreams"][0]["port"] = 5353 | ||
doc["spec"]["action"]["pass"] = f"tcp-{i}" | ||
create_resource_from_manifest(kube_apis.custom_objects, doc, namespace, "transportservers") | ||
|
||
@pytest.mark.delete | ||
def test_delete(self, request, kube_apis): | ||
count = int(request.config.getoption("--num")) | ||
# delete namespaces | ||
for i in range(1, count + 1): | ||
delete_namespace(kube_apis.v1, f"ns-{i}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters