From 917b0aeeaec015fcbaa09046f152b59d26a7760b Mon Sep 17 00:00:00 2001
From: Paul Abel
Date: Mon, 21 Jul 2025 16:42:51 +0100
Subject: [PATCH 1/2] Add service insight pytest for cross namespace vsr
---
tests/suite/test_v_s_route_service_insight.py | 58 +++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 tests/suite/test_v_s_route_service_insight.py
diff --git a/tests/suite/test_v_s_route_service_insight.py b/tests/suite/test_v_s_route_service_insight.py
new file mode 100644
index 0000000000..ae492547f5
--- /dev/null
+++ b/tests/suite/test_v_s_route_service_insight.py
@@ -0,0 +1,58 @@
+from unittest import mock
+
+import pytest
+import requests
+from suite.utils.resources_utils import (
+ ensure_response_from_backend,
+ wait_before_test,
+)
+
+
+@pytest.mark.vsr
+@pytest.mark.skip_for_nginx_oss
+@pytest.mark.parametrize(
+ "crd_ingress_controller, v_s_route_setup",
+ [
+ (
+ {
+ "type": "complete",
+ "extra_args": [
+ f"-enable-custom-resources",
+ f"-enable-service-insight",
+ ],
+ },
+ {"example": "virtual-server-route"},
+ )
+ ],
+ indirect=True,
+)
+class TestServiceInsightVsr:
+ def test_service_insight_vsr(
+ self,
+ kube_apis,
+ ingress_controller_endpoint,
+ crd_ingress_controller,
+ v_s_route_app_setup,
+ v_s_route_setup,
+ test_namespace,
+ ):
+ """
+ Test if service insight is working with cross namespace virtual server route
+ """
+
+ req_url = f"http://{v_s_route_setup.public_endpoint.public_ip}:{v_s_route_setup.public_endpoint.port}"
+
+ retry = 0
+ resp = mock.Mock()
+ resp.json.return_value = {}
+ resp.status_code == 502
+ host = v_s_route_setup.vs_host
+ req_url = f"http://{ingress_controller_endpoint.public_ip}:{ingress_controller_endpoint.service_insight_port}/probe/{host}"
+ ensure_response_from_backend(req_url, v_s_route_setup.vs_host)
+ while (resp.json() != {"Total": 6, "Up": 6, "Unhealthy": 0}) and retry < 5:
+ resp = requests.get(req_url)
+ wait_before_test()
+ retry = retry + 1
+
+ assert resp.status_code == 200, f"Expected 200 code for /probe/{host} but got {resp.status_code}"
+ assert resp.json() == {"Total": 6, "Up": 6, "Unhealthy": 0}
From 0789286424de3e675057789067556e7a5ac2fa5e Mon Sep 17 00:00:00 2001
From: Paul Abel
Date: Mon, 21 Jul 2025 16:50:54 +0100
Subject: [PATCH 2/2] remove duplicate req_url
---
tests/suite/test_v_s_route_service_insight.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/tests/suite/test_v_s_route_service_insight.py b/tests/suite/test_v_s_route_service_insight.py
index ae492547f5..4d8e4c8ea9 100644
--- a/tests/suite/test_v_s_route_service_insight.py
+++ b/tests/suite/test_v_s_route_service_insight.py
@@ -40,8 +40,6 @@ def test_service_insight_vsr(
Test if service insight is working with cross namespace virtual server route
"""
- req_url = f"http://{v_s_route_setup.public_endpoint.public_ip}:{v_s_route_setup.public_endpoint.port}"
-
retry = 0
resp = mock.Mock()
resp.json.return_value = {}