sdk_relay/tests/http_metrics.rs

24 lines
784 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 res = client
.get(format!("{}/metrics", url))
.send()
.await
.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");
}