Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Ryan committed Sep 16, 2024
1 parent ee6cf80 commit 538ec90
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ metadata:
spec:
listeners:
- name: udp-listener
port: 5353
port: 5454
protocol: UDP
- name: http-listener
port: 5353
port: 5454
protocol: HTTP
62 changes: 41 additions & 21 deletions tests/suite/test_udp_http_listeners_together.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import time

import pytest
from settings import TEST_DATA
from suite.utils.custom_resources_utils import patch_gc_from_yaml, patch_ts_from_yaml, read_custom_resource
from suite.utils.custom_resources_utils import (
create_ts_from_yaml,
delete_ts,
patch_gc_from_yaml,
read_custom_resource,
read_ts,
)
from suite.utils.resources_utils import get_first_pod_name, get_ts_nginx_template_conf, wait_before_test
from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_virtual_server_from_yaml


@pytest.mark.vs
@pytest.mark.ts
@pytest.mark.vs_ipv6
@pytest.mark.parametrize(
"crd_ingress_controller, virtual_server_setup, transport_server_setup",
[
Expand Down Expand Up @@ -35,16 +42,19 @@ def test_udp_and_http_listeners_together(
transport_server_setup,
):

wait_before_test()
existing_ts = read_ts(kube_apis.custom_objects, transport_server_setup.namespace, transport_server_setup.name)
# delete TS and VS first
delete_ts(kube_apis.custom_objects, existing_ts, transport_server_setup.namespace)

global_config_file = f"{TEST_DATA}/udp-http-listeners-together/global-configuration.yaml"
transport_server_file = f"{TEST_DATA}/udp-http-listeners-together/transport-server.yaml"
virtual_server_file = f"{TEST_DATA}/udp-http-listeners-together/virtual-server.yaml"
gc_resource_name = "nginx-configuration"
gc_namespace = "nginx-ingress"

patch_gc_from_yaml(kube_apis.custom_objects, gc_resource_name, global_config_file, gc_namespace)
patch_ts_from_yaml(
kube_apis.custom_objects, "transport-server", transport_server_file, transport_server_setup.namespace
)
create_ts_from_yaml(kube_apis.custom_objects, transport_server_file, transport_server_setup.namespace)
patch_virtual_server_from_yaml(
kube_apis.custom_objects, "virtual-server-status", virtual_server_file, virtual_server_setup.namespace
)
Expand All @@ -65,21 +75,31 @@ def test_udp_and_http_listeners_together(
ic_pod_name,
ingress_controller_prerequisites.namespace,
)
assert "listen 5353;" in vs_config
assert "listen 5353 udp;" in ts_config
assert "listen 5454;" in vs_config
assert "listen 5454 udp;" in ts_config

transport_server_response = read_custom_resource(
kube_apis.custom_objects,
transport_server_setup.namespace,
"transportservers",
"transport-server",
)
virtual_server_response = read_custom_resource(
kube_apis.custom_objects,
virtual_server_setup.namespace,
"virtualservers",
"virtual-server-status",
)
assert transport_server_response["status"] and transport_server_response["status"]["state"] == "Valid"
for _ in range(30):
transport_server_response = read_custom_resource(
kube_apis.custom_objects,
transport_server_setup.namespace,
"transportservers",
"transport-server",
)
if "status" in transport_server_response and transport_server_response["status"]["state"] == "Valid":
break
time.sleep(1)
else:
pytest.fail("TransportServer status did not become 'Valid' within the timeout period")

assert virtual_server_response["status"] and virtual_server_response["status"]["state"] == "Valid"
for _ in range(30):
virtual_server_response = read_custom_resource(
kube_apis.custom_objects,
virtual_server_setup.namespace,
"virtualservers",
"virtual-server-status",
)
if "status" in virtual_server_response and virtual_server_response["status"]["state"] == "Valid":
break
time.sleep(1)
else:
pytest.fail("VirtualServer status did not become 'Valid' within the timeout period")

0 comments on commit 538ec90

Please sign in to comment.