25 lines
887 B
Rust
25 lines
887 B
Rust
use std::time::Duration;
|
|
|
|
#[tokio::test]
|
|
async fn http_metrics_endpoint_should_return_expected_fields() {
|
|
let client = reqwest::Client::builder()
|
|
.timeout(Duration::from_secs(5))
|
|
.build()
|
|
.expect("cannot build client");
|
|
|
|
let url = std::env::var("SDK_RELAY_HTTP").unwrap_or_else(|_| "http://localhost:8091".to_string());
|
|
let resp = client.get(format!("{}/metrics", url)).send().await;
|
|
if resp.is_err() {
|
|
eprintln!("sdk_relay HTTP indisponible, test /metrics ignoré");
|
|
return;
|
|
}
|
|
let res = resp.expect("cannot call /metrics");
|
|
|
|
assert!(res.status().is_success(), "status: {}", res.status());
|
|
|
|
let json: serde_json::Value = res.json().await.expect("invalid json");
|
|
|
|
assert!(json.get("sync_metrics").is_some(), "missing sync_metrics");
|
|
assert!(json.get("system_metrics").is_some(), "missing system_metrics");
|
|
}
|