github.com/nginxinc/kubernetes-ingress@v1.12.5/tests/suite/test_healthcheck_uri.py (about) 1 import pytest 2 import requests 3 4 from suite.resources_utils import ensure_connection 5 6 7 @pytest.mark.ingresses 8 @pytest.mark.parametrize('ingress_controller, expected_responses', 9 [ 10 pytest.param({"extra_args": ["-health-status=true", 11 "-health-status-uri=/something-va(l)id/blabla"]}, 12 {"/something-va(l)id/blabla": 200, "/nginx-health": 404}, 13 id="custom-health-status-uri"), 14 pytest.param({"extra_args": ["-health-status=true"]}, 15 {"/something-va(l)id/blabla": 404, "/nginx-health": 200}, 16 id="default-health-status-uri"), 17 pytest.param({"extra_args": ["-health-status=false"]}, 18 {"/something-va(l)id/blabla": 404, "/nginx-health": 404}, 19 id="disable-health-status") 20 ], 21 indirect=["ingress_controller"]) 22 class TestHealthStatusURI: 23 def test_response_code(self, ingress_controller_endpoint, ingress_controller, expected_responses): 24 for uri in expected_responses: 25 req_url = f"http://{ingress_controller_endpoint.public_ip}:{ingress_controller_endpoint.port}{uri}" 26 ensure_connection(req_url, expected_responses[uri]) 27 resp = requests.get(req_url) 28 assert resp.status_code == expected_responses[uri],\ 29 f"Expected {expected_responses[uri]} code for {uri} but got {resp.status_code}"