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

Add more 502 checks for test backends #3275

Merged
merged 1 commit into from
Nov 18, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions tests/suite/test_v_s_route_split_traffic.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,20 @@ def test_several_requests(self, kube_apis, crd_ingress_controller, v_s_route_set
req_url = (
f"http://{v_s_route_setup.public_endpoint.public_ip}:{v_s_route_setup.public_endpoint.port}{split_path[0]}"
)
ensure_response_from_backend(req_url, v_s_route_setup.vs_host)
weights = get_weights_of_splitting(f"{TEST_DATA}/virtual-server-route-split-traffic/route-multiple.yaml")
upstreams = get_upstreams_of_splitting(f"{TEST_DATA}/virtual-server-route-split-traffic/route-multiple.yaml")
sum_weights = sum(weights)
ratios = [round(i / sum_weights, 1) for i in weights]

counter_v1, counter_v2 = 0, 0
for _ in range(100):
resp = requests.get(req_url, headers={"host": v_s_route_setup.vs_host})
if resp.status_code == 502:
print("Backend is not ready yet, skip.")
ensure_response_from_backend(req_url, v_s_route_setup.vs_host)
status_code = 502
while status_code == 502:
resp = requests.get(req_url, headers={"host": v_s_route_setup.vs_host})
status_code = resp.status_code
if status_code == 502:
print("Backend is not ready yet, skip.")
if upstreams[0] in resp.text in resp.text:
counter_v1 = counter_v1 + 1
elif upstreams[1] in resp.text in resp.text:
Expand Down
11 changes: 7 additions & 4 deletions tests/suite/test_virtual_server_split_traffic.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,20 @@ def get_upstreams_of_splitting(file) -> []:
)
class TestTrafficSplitting:
def test_several_requests(self, kube_apis, crd_ingress_controller, virtual_server_setup):
ensure_response_from_backend(virtual_server_setup.backend_1_url, virtual_server_setup.vs_host)
weights = get_weights_of_splitting(f"{TEST_DATA}/virtual-server-split-traffic/standard/virtual-server.yaml")
upstreams = get_upstreams_of_splitting(f"{TEST_DATA}/virtual-server-split-traffic/standard/virtual-server.yaml")
sum_weights = sum(weights)
ratios = [round(i / sum_weights, 1) for i in weights]

counter_v1, counter_v2 = 0, 0
for _ in range(100):
resp = requests.get(virtual_server_setup.backend_1_url, headers={"host": virtual_server_setup.vs_host})
if resp.status_code == 502:
print("Backend is not ready yet, skip.")
ensure_response_from_backend(virtual_server_setup.backend_1_url, virtual_server_setup.vs_host)
status_code = 502
while status_code == 502:
resp = requests.get(virtual_server_setup.backend_1_url, headers={"host": virtual_server_setup.vs_host})
status_code = resp.status_code
if status_code == 502:
print("Backend is not ready yet, skip.")
if upstreams[0] in resp.text in resp.text:
counter_v1 = counter_v1 + 1
elif upstreams[1] in resp.text in resp.text:
Expand Down
2 changes: 1 addition & 1 deletion tests/suite/test_watch_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_response_codes(self, ingress_controller, backend_setup, expected_respon
), f"Expected: {expected_responses[ing]} response code for {backend_setup.ingress_hosts[ing]}"


@pytest.mark.test
@pytest.mark.ingresses
@pytest.mark.parametrize(
"ingress_controller, expected_responses",
[
Expand Down