|
9 | 9 | get_namespace, |
10 | 10 | get_release_name, |
11 | 11 | kubectl_get, |
12 | | - kubectl_port_forward, |
| 12 | + kubectl_proxy, |
13 | 13 | wait_for_url, |
14 | 14 | ) |
15 | 15 |
|
@@ -184,26 +184,24 @@ def test_prometheus_targets_reachable(self) -> None: |
184 | 184 | service = json.loads(result.stdout)["items"][0] |
185 | 185 | service_name = service["metadata"]["name"] |
186 | 186 |
|
187 | | - # Try to port-forward to Prometheus |
188 | | - local_port = 19090 |
189 | | - prometheus_port = 80 |
| 187 | + # Try kubectl proxy instead of port-forward |
| 188 | + proxy_port = 8001 |
190 | 189 |
|
191 | 190 | process = None |
192 | 191 | try: |
193 | | - process = kubectl_port_forward( |
194 | | - service_name, local_port, prometheus_port, namespace |
195 | | - ) |
| 192 | + process = kubectl_proxy(proxy_port) |
| 193 | + |
| 194 | + # Build proxy URL for Prometheus service |
| 195 | + proxy_url = f"http://localhost:{proxy_port}/api/v1/namespaces/{namespace}/services/{service_name}:80/proxy" |
196 | 196 |
|
197 | | - # Wait for port forward to establish |
198 | | - if not wait_for_url( |
199 | | - f"http://localhost:{local_port}/api/v1/targets" |
200 | | - ): |
201 | | - pytest.skip("Could not establish connection to Prometheus") |
| 197 | + # Wait for proxy to establish |
| 198 | + if not wait_for_url(f"{proxy_url}/api/v1/targets"): |
| 199 | + pytest.skip( |
| 200 | + "Could not establish connection to Prometheus via proxy" |
| 201 | + ) |
202 | 202 |
|
203 | 203 | # Check Prometheus targets |
204 | | - response = requests.get( |
205 | | - f"http://localhost:{local_port}/api/v1/targets" |
206 | | - ) |
| 204 | + response = requests.get(f"{proxy_url}/api/v1/targets") |
207 | 205 | assert response.status_code == 200, ( |
208 | 206 | "Failed to get Prometheus targets" |
209 | 207 | ) |
@@ -269,10 +267,10 @@ def test_hpa_resources_exist(self) -> None: |
269 | 267 |
|
270 | 268 | # Expected HPA names based on the Helm chart |
271 | 269 | expected_hpas = [ |
272 | | - f"{release}-pgstac", |
273 | | - f"{release}-raster", |
274 | | - f"{release}-stac", |
275 | | - f"{release}-vector", |
| 270 | + f"{release}-multidim-hpa", |
| 271 | + f"{release}-raster-hpa", |
| 272 | + f"{release}-stac-hpa", |
| 273 | + f"{release}-vector-hpa", |
276 | 274 | ] |
277 | 275 |
|
278 | 276 | found_hpas = {hpa["metadata"]["name"] for hpa in hpas} |
@@ -401,20 +399,20 @@ def test_grafana_service_accessibility(self) -> None: |
401 | 399 | service = services[0] |
402 | 400 | service_name = service["metadata"]["name"] |
403 | 401 |
|
404 | | - # Port forward to Grafana |
405 | | - local_port = 13000 |
406 | | - grafana_port = 80 |
| 402 | + # Use kubectl proxy to access Grafana |
| 403 | + proxy_port = 8002 |
407 | 404 |
|
408 | 405 | process = None |
409 | 406 | try: |
410 | | - process = kubectl_port_forward( |
411 | | - service_name, local_port, grafana_port, namespace |
412 | | - ) |
| 407 | + process = kubectl_proxy(proxy_port) |
| 408 | + |
| 409 | + # Build proxy URL for Grafana service |
| 410 | + proxy_url = f"http://localhost:{proxy_port}/api/v1/namespaces/{namespace}/services/{service_name}:80/proxy" |
413 | 411 |
|
414 | | - if not wait_for_url(f"http://localhost:{local_port}/api/health"): |
415 | | - pytest.skip("Could not connect to Grafana") |
| 412 | + if not wait_for_url(f"{proxy_url}/api/health"): |
| 413 | + pytest.skip("Could not connect to Grafana via proxy") |
416 | 414 |
|
417 | | - response = requests.get(f"http://localhost:{local_port}/api/health") |
| 415 | + response = requests.get(f"{proxy_url}/api/health") |
418 | 416 | assert response.status_code == 200, "Grafana health check failed" |
419 | 417 |
|
420 | 418 | health_data = response.json() |
|
0 commit comments