tests: use endpoint http wrapper to get auth (#11628)

## Problem

`test_compute_startup_simple` and `test_compute_ondemand_slru_startup`
are failing.

This test implicitly asserts that the metrics.json endpoint succeeds and
returns all expected metrics, but doesn't make it easy to see what went
wrong if it doesn't (e.g. in this failure
https://neon-github-public-dev.s3.amazonaws.com/reports/main/14513210240/index.html#suites/13d8e764c394daadbad415a08454c04e/b0f92a86b2ed309f/)

In this case, it was failing because of a missing auth token, because it
was using `requests` directly instead of using the endpoint http client
type.

## Summary of changes

- Use endpoint http wrapper to get raise_for_status & auth token
This commit is contained in:
John Spray
2025-04-17 16:03:23 +01:00
committed by GitHub
parent 2c56c46d48
commit d4c059a884

View File

@@ -3,7 +3,6 @@ from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
import requests
from fixtures.benchmark_fixture import MetricReport, NeonBenchmarker
if TYPE_CHECKING:
@@ -68,9 +67,7 @@ def test_compute_startup_simple(
endpoint.safe_psql("select 1;")
# Get metrics
metrics = requests.get(
f"http://localhost:{endpoint.external_http_port}/metrics.json"
).json()
metrics = endpoint.http_client().metrics_json()
durations = {
"wait_for_spec_ms": f"{i}_wait_for_spec",
"sync_safekeepers_ms": f"{i}_sync_safekeepers",
@@ -155,9 +152,7 @@ def test_compute_ondemand_slru_startup(
assert sum == 1000000
# Get metrics
metrics = requests.get(
f"http://localhost:{endpoint.external_http_port}/metrics.json"
).json()
metrics = endpoint.http_client().metrics_json()
durations = {
"wait_for_spec_ms": f"{slru}_{i}_wait_for_spec",
"sync_safekeepers_ms": f"{slru}_{i}_sync_safekeepers",