2020-04-17 12:11:25 +00:00
|
|
|
use anyhow::{Error};
|
2019-05-16 08:24:23 +00:00
|
|
|
|
2020-08-06 13:46:01 +00:00
|
|
|
use proxmox_backup::api2::types::Userid;
|
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-08-06 13:46:01 +00:00
|
|
|
let username = Userid::root_userid();
|
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);
|
|
|
|
|
|
|
|
let client = HttpClient::new(host, username, options)?;
|
2019-05-16 08:24:23 +00:00
|
|
|
|
2019-07-25 11:44:01 +00:00
|
|
|
let backup_time = chrono::Utc::now();
|
|
|
|
|
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
|
|
|
}
|