proxmox-backup-client benchmark: add --verbose flag
This commit is contained in:
parent
7884e7ef4f
commit
323b2f3dd6
@ -30,6 +30,11 @@ use crate::{
|
||||
schema: REPO_URL_SCHEMA,
|
||||
optional: true,
|
||||
},
|
||||
verbose: {
|
||||
description: "Verbose output.",
|
||||
type: bool,
|
||||
optional: true,
|
||||
},
|
||||
keyfile: {
|
||||
schema: KEYFILE_SCHEMA,
|
||||
optional: true,
|
||||
@ -48,6 +53,8 @@ pub async fn benchmark(
|
||||
|
||||
let keyfile = param["keyfile"].as_str().map(PathBuf::from);
|
||||
|
||||
let verbose = param["verbose"].as_bool().unwrap_or(false);
|
||||
|
||||
let crypt_config = match keyfile {
|
||||
None => None,
|
||||
Some(path) => {
|
||||
@ -62,18 +69,19 @@ pub async fn benchmark(
|
||||
let client = connect(repo.host(), repo.user())?;
|
||||
record_repository(&repo);
|
||||
|
||||
println!("Connecting to backup server");
|
||||
let client = BackupWriter::start(
|
||||
client,
|
||||
crypt_config.clone(),
|
||||
repo.store(),
|
||||
"host",
|
||||
"benshmark",
|
||||
"benchmark",
|
||||
backup_time,
|
||||
false,
|
||||
).await?;
|
||||
|
||||
println!("Start upload speed test");
|
||||
let speed = client.upload_speedtest().await?;
|
||||
let speed = client.upload_speedtest(verbose).await?;
|
||||
|
||||
println!("Upload speed: {} MiB/s", speed);
|
||||
|
||||
|
@ -274,7 +274,7 @@ impl BackupWriter {
|
||||
})
|
||||
}
|
||||
|
||||
fn response_queue() -> (
|
||||
fn response_queue(verbose: bool) -> (
|
||||
mpsc::Sender<h2::client::ResponseFuture>,
|
||||
oneshot::Receiver<Result<(), Error>>
|
||||
) {
|
||||
@ -298,11 +298,11 @@ impl BackupWriter {
|
||||
tokio::spawn(
|
||||
verify_queue_rx
|
||||
.map(Ok::<_, Error>)
|
||||
.try_for_each(|response: h2::client::ResponseFuture| {
|
||||
.try_for_each(move |response: h2::client::ResponseFuture| {
|
||||
response
|
||||
.map_err(Error::from)
|
||||
.and_then(H2Client::h2api_response)
|
||||
.map_ok(|result| println!("RESPONSE: {:?}", result))
|
||||
.map_ok(move |result| if verbose { println!("RESPONSE: {:?}", result) })
|
||||
.map_err(|err| format_err!("pipelined request failed: {}", err))
|
||||
})
|
||||
.map(|result| {
|
||||
@ -600,7 +600,8 @@ impl BackupWriter {
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn upload_speedtest(&self) -> Result<usize, Error> {
|
||||
/// Upload speed test - prints result ot stdout
|
||||
pub async fn upload_speedtest(&self, verbose: bool) -> Result<usize, Error> {
|
||||
|
||||
let mut data = vec![];
|
||||
// generate pseudo random byte sequence
|
||||
@ -615,7 +616,7 @@ impl BackupWriter {
|
||||
|
||||
let mut repeat = 0;
|
||||
|
||||
let (upload_queue, upload_result) = Self::response_queue();
|
||||
let (upload_queue, upload_result) = Self::response_queue(verbose);
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
|
||||
@ -627,7 +628,7 @@ impl BackupWriter {
|
||||
|
||||
let mut upload_queue = upload_queue.clone();
|
||||
|
||||
println!("send test data ({} bytes)", data.len());
|
||||
if verbose { println!("send test data ({} bytes)", data.len()); }
|
||||
let request = H2Client::request_builder("localhost", "POST", "speedtest", None, None).unwrap();
|
||||
let request_future = self.h2.send_request(request, Some(bytes::Bytes::from(data.clone()))).await?;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user