MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / metrics_node_id_matches_shared_state

Function metrics_node_id_matches_shared_state

nodedb/tests/http_metrics.rs:200–229  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

198
199#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
200async 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}

Callers

nothing calls this directly

Calls 7

textMethod · 0.80
start_httpFunction · 0.70
expectMethod · 0.45
sendMethod · 0.45
getMethod · 0.45
findMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected