From 4b13fa863265074d55279460adc79fa7845ae507 Mon Sep 17 00:00:00 2001 From: Michael Pleshakov Date: Fri, 16 Apr 2021 16:00:35 -0700 Subject: [PATCH 1/2] Fix ensuring connection in tests * Add timeout for establishing a connection to prevent potential "hangs" of the test runs. The problem was noticeable when running tests in kind. * Increase the number of tries to make sure the Ingress Controller pod has enough time to get ready. When running tests in kind locally the number of tries sometimes was not enough. --- tests/suite/resources_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/suite/resources_utils.py b/tests/suite/resources_utils.py index c6a2f76051..c51f7004ff 100644 --- a/tests/suite/resources_utils.py +++ b/tests/suite/resources_utils.py @@ -1047,9 +1047,9 @@ def ensure_connection(request_url, expected_code=404) -> None: :param expected_code: response code :return: """ - for _ in range(4): + for _ in range(10): try: - resp = requests.get(request_url, verify=False) + resp = requests.get(request_url, verify=False, timeout=5) if resp.status_code == expected_code: return except Exception as ex: From d150571c103d903d2ecb8caa2aa93633ba3b8d26 Mon Sep 17 00:00:00 2001 From: Michael Pleshakov Date: Fri, 16 Apr 2021 16:01:51 -0700 Subject: [PATCH 2/2] Ensure connection in Ingress TLS tests Ensure connection to NGINX before running tests. Without ensuring, sometimes the first connection to NGINX would hang (timeout). The problem is noticable when running tests in kind. --- tests/suite/test_tls.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/suite/test_tls.py b/tests/suite/test_tls.py index 0f0542b3df..1565683a8e 100644 --- a/tests/suite/test_tls.py +++ b/tests/suite/test_tls.py @@ -1,7 +1,7 @@ import pytest from suite.resources_utils import create_ingress_from_yaml, delete_items_from_yaml, wait_before_test, \ - create_secret_from_yaml, delete_secret, replace_secret, is_secret_present + create_secret_from_yaml, delete_secret, replace_secret, is_secret_present, ensure_connection_to_public_endpoint from suite.yaml_utils import get_first_ingress_host_from_yaml, get_name_from_yaml from suite.ssl_utils import get_server_certificate_subject from settings import TEST_DATA @@ -58,6 +58,9 @@ def tls_setup(request, kube_apis, ingress_controller_prerequisites, ingress_cont ingress_host = get_first_ingress_host_from_yaml(ingress_path) secret_name = get_name_from_yaml(f"{test_data_path}/tls-secret.yaml") + ensure_connection_to_public_endpoint(ingress_controller_endpoint.public_ip, ingress_controller_endpoint.port, + ingress_controller_endpoint.port_ssl) + def fin(): print("Clean up TLS setup") delete_items_from_yaml(kube_apis, ingress_path, test_namespace)