Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ aes = "0.8.4"
ctr = "0.9.2"
cipher = "0.4.4"
pbkdf2 = "0.12.2"
pin-project = "1"
sha2 = "0.10.9"
scrypt = "0.11.0"
unicode-normalization = "0.1.25"
Expand Down
35 changes: 23 additions & 12 deletions crates/cli/src/commands/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,17 +415,29 @@ mod tests {
}

#[tokio::test]
#[ignore = "/metrics endpoint not implemented"]
async fn serve_addr_metrics() {
let monitoring_addr = net::TcpListener::bind("127.0.0.1:0")
.await
.unwrap()
.local_addr()
.unwrap()
.to_string();
let monitoring_url = format!("http://{monitoring_addr}/metrics");

with_relay_server(
|_| {},
async |cfg| {
let response = relay_server_get(cfg, "/metrics").await.unwrap();
move |args| {
args.debug_monitoring.monitor_addr = Some(monitoring_addr);
},
async move |_cfg| {
let response = retry_get(&monitoring_url).await.unwrap();
let body = response.text().await.unwrap();

dbg!(&body);

assert!(body.contains("libp2p_relaysvc_"));
assert!(body.contains("relay_p2p_connection_total"));
assert!(body.contains("relay_p2p_active_connections"));
assert!(body.contains("relay_p2p_ping_latency"));
assert!(body.contains("relay_p2p_network_sent_bytes"));
assert!(body.contains("relay_p2p_network_receive_bytes"));
assert!(body.ends_with("# EOF\n"));
},
)
.await
Expand Down Expand Up @@ -523,12 +535,11 @@ mod tests {
path: &str,
) -> Result<reqwest::Response, reqwest::Error> {
let http_address = cfg.http_addr.unwrap();
let request = async || {
reqwest::get(format!("http://{}{}", http_address, path))
.await
.and_then(|r| r.error_for_status())
};
retry_get(&format!("http://{}{}", http_address, path)).await
}

async fn retry_get(url: &str) -> Result<reqwest::Response, reqwest::Error> {
let request = async || reqwest::get(url).await.and_then(|r| r.error_for_status());
let mut backoff = backon::ExponentialBuilder::default()
.with_min_delay(time::Duration::from_millis(200))
.with_max_delay(time::Duration::from_secs(2))
Expand Down
1 change: 1 addition & 0 deletions crates/dkg/src/bcast/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ mod tests {
NodeType::TCP,
false,
p2p_context.clone(),
None,
move |builder, _keypair| builder.with_inner(behaviour),
)?;
let addr: Multiaddr = format!("/ip4/127.0.0.1/tcp/{}", ports[index]).parse()?;
Expand Down
1 change: 1 addition & 0 deletions crates/dkg/src/exchanger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ mod tests {
NodeType::TCP,
false,
p2p_context,
None,
move |builder, _key| builder.with_inner(behaviour),
)?;

Expand Down
1 change: 1 addition & 0 deletions crates/dkg/src/nodesigs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ mod tests {
NodeType::TCP,
false,
p2p_context,
None,
move |builder, _| builder.with_inner(behaviour),
)?;

Expand Down
1 change: 1 addition & 0 deletions crates/p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ serde.workspace = true
serde_json.workspace = true
pluto-core.workspace = true
backon.workspace = true
pin-project.workspace = true
reqwest.workspace = true
unsigned-varint.workspace = true
url.workspace = true
Expand Down
Loading
Loading