Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for non 50x 404 response #5851

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion tests/suite/test_ac_policies_vsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"},
Expand All @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion tests/suite/utils/resources_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...")


Expand Down