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

Function start_http

nodedb/tests/http_metrics.rs:27–61  ·  view source on GitHub ↗
(auth_mode: AuthMode)

Source from the content-addressed store, hash-verified

25}
26
27async fn start_http(auth_mode: AuthMode) -> TestServer {
28 let dir = tempfile::tempdir().expect("tempdir");
29 let wal =
30 Arc::new(WalManager::open_for_testing(&dir.path().join("metrics.wal")).expect("open wal"));
31 let (dispatcher, _data_sides) = Dispatcher::new(1, 64);
32 let shared = SharedState::new(dispatcher, wal);
33
34 let listener = tokio::net::TcpListener::bind("127.0.0.1:0")
35 .await
36 .expect("bind");
37 let local_addr = listener.local_addr().expect("local addr");
38
39 let (bus, _) = nodedb::control::shutdown::ShutdownBus::new(Arc::clone(&shared.shutdown));
40 let shared_http = Arc::clone(&shared);
41 let handle = tokio::spawn(async move {
42 nodedb::control::server::http::server::run_with_listener(
43 listener,
44 shared_http,
45 auth_mode,
46 None,
47 bus,
48 )
49 .await
50 .ok();
51 });
52
53 tokio::time::sleep(Duration::from_millis(40)).await;
54
55 TestServer {
56 local_addr,
57 shared,
58 _server: handle,
59 _dir: dir,
60 }
61}
62
63// ─── Success path ────────────────────────────────────────────────────────────
64

Calls 7

run_with_listenerFunction · 0.85
joinMethod · 0.80
spawnFunction · 0.50
expectMethod · 0.45
pathMethod · 0.45
local_addrMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected