Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 14 additions & 9 deletions src/aim_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,21 @@ impl CloudflareAimResults {
)?
.await?;

let (status, status_text) = (response.status(), response.status().to_string());
let status = response.status();
let body = response.into_body().collect().await?.to_bytes();

debug!(
"aim upload response: {status} ({status_text}); {}",
String::from_utf8_lossy(&body)
);

if status != 200 {
anyhow::bail!("error uploading aim results");
let body = String::from_utf8_lossy(&body);

debug!("aim upload response: {status}; {body}");

if !status.is_success() {
let excerpt: String = body
.split_whitespace()
.collect::<Vec<_>>()
.join(" ")
.chars()
.take(200)
.collect();
anyhow::bail!("server responded {status}: {excerpt}");
}

Ok(())
Expand Down
8 changes: 7 additions & 1 deletion src/nq_core/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ impl ThroughputClient {
tracing::debug!("created request: {request:?}");

let failure_time = Arc::clone(&time);
let teardown = shutdown.clone();
tokio::spawn(
async move {
if let Err(error) = self
Expand All @@ -193,7 +194,12 @@ impl ThroughputClient {
)
.await
{
error!("error sending ThroughputClient request: {error:#}");
// Test teardown closes every connection while requests may still be in flight
if teardown.is_cancelled() {
debug!("ThroughputClient request cancelled by shutdown: {error:#}");
} else {
error!("error sending ThroughputClient request: {error:#}");
}

// An upload's failure (rejected status, reset stream, dead
// connection) is invisible to its request body, which just
Expand Down
4 changes: 2 additions & 2 deletions src/rpm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use http_body_util::BodyExt;
use serde::Deserialize;
use tokio::time::timeout;
use tokio_util::sync::CancellationToken;
use tracing::{debug, error, info, warn};
use tracing::{debug, info, warn};

use crate::aim_report::CloudflareAimResults;
use crate::args::rpm::{RpmArgs, SMALL_UPLOAD_BYTES_PER_REQUEST};
Expand Down Expand Up @@ -158,7 +158,7 @@ pub async fn run(cli_config: RpmArgs) -> anyhow::Result<()> {
if !cli_config.disable_aim_scores {
debug!("uploading aim report");
if let Err(e) = aim_results.upload().await {
error!("error uploading aim results: {e}");
warn!("error uploading aim results: {e}");
}
}
});
Expand Down
Loading