|
2 | 2 | from settings import TEST_DATA |
3 | 3 | from suite.utils.custom_assertions import assert_event |
4 | 4 | from suite.utils.custom_resources_utils import is_dnsendpoint_present |
5 | | -from suite.utils.resources_utils import get_events, wait_before_test |
| 5 | +from suite.utils.resources_utils import get_events, patch_namespace_with_label, wait_before_test |
6 | 6 | from suite.utils.vs_vsr_resources_utils import patch_virtual_server_from_yaml |
7 | 7 | from suite.utils.yaml_utils import get_name_from_yaml, get_namespace_from_yaml |
8 | 8 |
|
@@ -65,3 +65,60 @@ def test_update_to_ed_in_vs( |
65 | 65 | wait_before_test(5) |
66 | 66 | events = get_events(kube_apis.v1, virtual_server_setup.namespace) |
67 | 67 | assert_event(vs_event_update_text, events) |
| 68 | + |
| 69 | + |
| 70 | +@pytest.mark.vs |
| 71 | +@pytest.mark.smoke |
| 72 | +@pytest.mark.parametrize( |
| 73 | + "crd_ingress_controller_with_ed, create_externaldns, virtual_server_setup", |
| 74 | + [ |
| 75 | + ( |
| 76 | + { |
| 77 | + "type": "complete", |
| 78 | + "extra_args": [ |
| 79 | + f"-enable-custom-resources", |
| 80 | + f"-enable-external-dns", |
| 81 | + f"-watch-namespace-label=app=watch", |
| 82 | + ], |
| 83 | + }, |
| 84 | + {}, |
| 85 | + {"example": "virtual-server-external-dns", "app_type": "simple"}, |
| 86 | + ) |
| 87 | + ], |
| 88 | + indirect=True, |
| 89 | +) |
| 90 | +class TestExternalDNSVirtualServerWatchLabel: |
| 91 | + def test_responses_after_setup( |
| 92 | + self, kube_apis, crd_ingress_controller_with_ed, create_externaldns, virtual_server_setup, test_namespace |
| 93 | + ): |
| 94 | + dns_ep_name = get_name_from_yaml(VS_YAML) |
| 95 | + print("\nStep 0: Verify DNSEndpoint is not created without watched label") |
| 96 | + retry = 0 |
| 97 | + dep = is_dnsendpoint_present(kube_apis.custom_objects, dns_ep_name, virtual_server_setup.namespace) |
| 98 | + # add a wait to avoid a false negative |
| 99 | + wait_before_test(30) |
| 100 | + dep = is_dnsendpoint_present(kube_apis.custom_objects, dns_ep_name, virtual_server_setup.namespace) |
| 101 | + assert dep is False |
| 102 | + print("\nStep 1: Verify DNSEndpoint exists after label is added to namespace") |
| 103 | + patch_namespace_with_label(kube_apis.v1, test_namespace, "watch", f"{TEST_DATA}/common/ns-patch.yaml") |
| 104 | + wait_before_test() |
| 105 | + retry = 0 |
| 106 | + dep = is_dnsendpoint_present(kube_apis.custom_objects, dns_ep_name, virtual_server_setup.namespace) |
| 107 | + while dep == False and retry <= 60: |
| 108 | + dep = is_dnsendpoint_present(kube_apis.custom_objects, dns_ep_name, virtual_server_setup.namespace) |
| 109 | + retry += 1 |
| 110 | + wait_before_test(1) |
| 111 | + print(f"DNSEndpoint not created, retrying... #{retry}") |
| 112 | + assert dep is True |
| 113 | + print("\nStep 2: Verify external-dns picked up the record") |
| 114 | + pod_ns = get_namespace_from_yaml(f"{TEST_DATA}/virtual-server-external-dns/external-dns.yaml") |
| 115 | + pod_name = kube_apis.v1.list_namespaced_pod(pod_ns).items[0].metadata.name |
| 116 | + log_contents = kube_apis.v1.read_namespaced_pod_log(pod_name, pod_ns) |
| 117 | + wanted_string = "CREATE: virtual-server.example.com 0 IN A" |
| 118 | + retry = 0 |
| 119 | + while wanted_string not in log_contents and retry <= 60: |
| 120 | + log_contents = kube_apis.v1.read_namespaced_pod_log(pod_name, pod_ns) |
| 121 | + retry += 1 |
| 122 | + wait_before_test(1) |
| 123 | + print(f"External DNS not updated, retrying... #{retry}") |
| 124 | + assert wanted_string in log_contents |
0 commit comments