From 8eb9267a8c5250bb6fbbba456612cdfeb2a98cbc Mon Sep 17 00:00:00 2001 From: Venktesh Date: Tue, 25 Jun 2024 12:17:52 +0100 Subject: [PATCH] check for non 50x 404 response --- tests/suite/test_ac_policies_vsr.py | 14 +++++++++++++- tests/suite/utils/resources_utils.py | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/suite/test_ac_policies_vsr.py b/tests/suite/test_ac_policies_vsr.py index d725021f59..ede342a830 100644 --- a/tests/suite/test_ac_policies_vsr.py +++ b/tests/suite/test_ac_policies_vsr.py @@ -3,7 +3,7 @@ from settings import DEPLOYMENTS, TEST_DATA from suite.utils.custom_resources_utils import read_custom_resource from suite.utils.policy_resources_utils import create_policy_from_yaml, delete_policy -from suite.utils.resources_utils import replace_configmap_from_yaml, wait_before_test +from suite.utils.resources_utils import ensure_response_from_backend, replace_configmap_from_yaml, wait_before_test from suite.utils.vs_vsr_resources_utils import patch_v_s_route_from_yaml, patch_virtual_server_from_yaml std_cm_src = f"{DEPLOYMENTS}/common/nginx-config.yaml" @@ -91,6 +91,12 @@ def test_deny_policy_vsr( Test if ip (10.0.0.1) block-listing is working (policy specified in vsr subroute): default(no policy) -> deny """ req_url = f"http://{v_s_route_setup.public_endpoint.public_ip}:{v_s_route_setup.public_endpoint.port}" + ensure_response_from_backend( + f"{req_url}{v_s_route_setup.route_m.paths[0]}", + v_s_route_setup.vs_host, + additional_headers={"X-Real-IP": "10.0.0.1"}, + check404=True, + ) resp = requests.get( f"{req_url}{v_s_route_setup.route_m.paths[0]}", headers={"host": v_s_route_setup.vs_host, "X-Real-IP": "10.0.0.1"}, @@ -107,6 +113,12 @@ def test_deny_policy_vsr( v_s_route_setup.route_m.namespace, ) wait_before_test() + ensure_response_from_backend( + f"{req_url}{v_s_route_setup.route_m.paths[0]}", + v_s_route_setup.vs_host, + additional_headers={"X-Real-IP": "10.0.0.1"}, + check404=True, + ) policy_info = read_custom_resource( kube_apis.custom_objects, v_s_route_setup.route_m.namespace, "policies", pol_name ) diff --git a/tests/suite/utils/resources_utils.py b/tests/suite/utils/resources_utils.py index 1fb0cb0133..da43707e95 100644 --- a/tests/suite/utils/resources_utils.py +++ b/tests/suite/utils/resources_utils.py @@ -1595,7 +1595,7 @@ def ensure_response_from_backend(req_url, host, additional_headers=None, check40 if resp.status_code != 502 and resp.status_code != 504: print(f"After {_} retries at 1 second interval, got non 502|504 response. Continue with tests...") return - time.sleep(1) + wait_before_test() pytest.fail(f"Keep getting 502|504 from {req_url} after 60 seconds. Exiting...")