2022-04-10 15:44:34 +00:00
|
|
|
use anyhow::Error;
|
2019-05-16 08:24:23 +00:00
|
|
|
|
2022-04-21 13:04:59 +00:00
|
|
|
use pbs_api_types::{Authid, BackupNamespace, BackupType};
|
2022-04-10 15:44:34 +00:00
|
|
|
use pbs_client::{BackupWriter, HttpClient, HttpClientOptions};
|
2019-05-16 08:24:23 +00:00
|
|
|
|
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
|
|
|
|
2021-01-25 13:42:57 +00:00
|
|
|
let options = HttpClientOptions::default()
|
2020-01-25 11:18:00 +00:00
|
|
|
.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
|
|
|
|
2021-10-08 09:19:37 +00:00
|
|
|
let backup_time = proxmox_time::epoch_i64();
|
2019-07-25 11:44:01 +00:00
|
|
|
|
2022-04-10 15:44:34 +00:00
|
|
|
let client = BackupWriter::start(
|
|
|
|
client,
|
|
|
|
None,
|
|
|
|
datastore,
|
2022-05-09 13:39:29 +00:00
|
|
|
&BackupNamespace::root(),
|
|
|
|
&(BackupType::Host, "speedtest".to_string(), backup_time).into(),
|
2022-04-10 15:44:34 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2022-04-10 15:44:34 +00:00
|
|
|
fn main() {
|
2021-11-19 16:36:06 +00:00
|
|
|
match proxmox_async::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
|
|
|
}
|