2020-04-17 12:11:25 +00:00
|
|
|
use anyhow::{Error};
|
2019-05-16 08:24:23 +00:00
|
|
|
|
2020-10-08 13:19:39 +00:00
|
|
|
use proxmox_backup::api2::types::Authid;
|
2019-05-16 08:24:23 +00:00
|
|
|
use proxmox_backup::client::*;
|
|
|
|
|
2020-07-17 13:39:17 +00:00
|
|
|
async fn upload_speed() -> Result<f64, Error> {
|
2019-05-16 08:24:23 +00:00
|
|
|
|
|
|
|
let host = "localhost";
|
|
|
|
let datastore = "store2";
|
|
|
|
|
2020-10-08 13:19:39 +00:00
|
|
|
let auth_id = Authid::root_auth_id();
|
2019-05-16 08:24:23 +00:00
|
|
|
|
2020-01-25 11:18:00 +00:00
|
|
|
let options = HttpClientOptions::new()
|
|
|
|
.interactive(true)
|
|
|
|
.ticket_cache(true);
|
|
|
|
|
2020-10-08 13:19:39 +00:00
|
|
|
let client = HttpClient::new(host, 8007, auth_id, options)?;
|
2019-05-16 08:24:23 +00:00
|
|
|
|
2020-09-12 13:10:47 +00:00
|
|
|
let backup_time = proxmox::tools::time::epoch_i64();
|
2019-07-25 11:44:01 +00:00
|
|
|
|
2020-09-10 07:34:51 +00:00
|
|
|
let client = BackupWriter::start(client, None, datastore, "host", "speedtest", backup_time, false, true).await?;
|
2019-05-16 08:24:23 +00:00
|
|
|
|
2019-05-23 05:20:05 +00:00
|
|
|
println!("start upload speed test");
|
2020-07-17 13:39:17 +00:00
|
|
|
let res = client.upload_speedtest(true).await?;
|
2019-05-16 08:24:23 +00:00
|
|
|
|
|
|
|
Ok(res)
|
|
|
|
}
|
|
|
|
|
2020-01-20 11:52:22 +00:00
|
|
|
fn main() {
|
|
|
|
match proxmox_backup::tools::runtime::main(upload_speed()) {
|
2019-08-29 07:58:20 +00:00
|
|
|
Ok(mbs) => {
|
|
|
|
println!("average upload speed: {} MB/s", mbs);
|
|
|
|
}
|
|
|
|
Err(err) => {
|
|
|
|
eprintln!("ERROR: {}", err);
|
2019-05-16 08:24:23 +00:00
|
|
|
}
|
2019-08-29 07:58:20 +00:00
|
|
|
}
|
2019-05-16 08:24:23 +00:00
|
|
|
}
|