| 198 | |
| 199 | #[tokio::test(flavor = "multi_thread", worker_threads = 2)] |
| 200 | async fn metrics_node_id_matches_shared_state() { |
| 201 | let srv = start_http(AuthMode::Trust).await; |
| 202 | let expected_node_id = srv.shared.node_id; |
| 203 | |
| 204 | let url = format!("http://{}/metrics", srv.local_addr); |
| 205 | let body = reqwest::Client::new() |
| 206 | .get(&url) |
| 207 | .send() |
| 208 | .await |
| 209 | .expect("GET /metrics") |
| 210 | .text() |
| 211 | .await |
| 212 | .expect("body"); |
| 213 | |
| 214 | let id_line = body |
| 215 | .lines() |
| 216 | .find(|l| l.starts_with("nodedb_node_id ")) |
| 217 | .expect("nodedb_node_id line not found"); |
| 218 | |
| 219 | let reported: u64 = id_line |
| 220 | .trim_start_matches("nodedb_node_id ") |
| 221 | .trim() |
| 222 | .parse() |
| 223 | .expect("nodedb_node_id must be a u64"); |
| 224 | |
| 225 | assert_eq!( |
| 226 | reported, expected_node_id, |
| 227 | "nodedb_node_id in /metrics must match SharedState.node_id" |
| 228 | ); |
| 229 | } |