Skip to content

Commit ab54158

Browse files
authored
Add service insight pytest for cross namespace VSR (#8055)
* Add service insight pytest for cross namespace vsr * remove duplicate req_url
1 parent 3f05f59 commit ab54158

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
from unittest import mock
2+
3+
import pytest
4+
import requests
5+
from suite.utils.resources_utils import (
6+
ensure_response_from_backend,
7+
wait_before_test,
8+
)
9+
10+
11+
@pytest.mark.vsr
12+
@pytest.mark.skip_for_nginx_oss
13+
@pytest.mark.parametrize(
14+
"crd_ingress_controller, v_s_route_setup",
15+
[
16+
(
17+
{
18+
"type": "complete",
19+
"extra_args": [
20+
f"-enable-custom-resources",
21+
f"-enable-service-insight",
22+
],
23+
},
24+
{"example": "virtual-server-route"},
25+
)
26+
],
27+
indirect=True,
28+
)
29+
class TestServiceInsightVsr:
30+
def test_service_insight_vsr(
31+
self,
32+
kube_apis,
33+
ingress_controller_endpoint,
34+
crd_ingress_controller,
35+
v_s_route_app_setup,
36+
v_s_route_setup,
37+
test_namespace,
38+
):
39+
"""
40+
Test if service insight is working with cross namespace virtual server route
41+
"""
42+
43+
retry = 0
44+
resp = mock.Mock()
45+
resp.json.return_value = {}
46+
resp.status_code == 502
47+
host = v_s_route_setup.vs_host
48+
req_url = f"http://{ingress_controller_endpoint.public_ip}:{ingress_controller_endpoint.service_insight_port}/probe/{host}"
49+
ensure_response_from_backend(req_url, v_s_route_setup.vs_host)
50+
while (resp.json() != {"Total": 6, "Up": 6, "Unhealthy": 0}) and retry < 5:
51+
resp = requests.get(req_url)
52+
wait_before_test()
53+
retry = retry + 1
54+
55+
assert resp.status_code == 200, f"Expected 200 code for /probe/{host} but got {resp.status_code}"
56+
assert resp.json() == {"Total": 6, "Up": 6, "Unhealthy": 0}

0 commit comments

Comments
 (0)