]>
Commit | Line | Data |
---|---|---|
a22d3388 | 1 | use anyhow::Error; |
adec8ea2 | 2 | |
8c74349b | 3 | use pbs_api_types::{Authid, BackupNamespace, BackupType}; |
a22d3388 | 4 | use pbs_client::{BackupWriter, HttpClient, HttpClientOptions}; |
adec8ea2 | 5 | |
eb13d915 | 6 | async fn upload_speed() -> Result<f64, Error> { |
adec8ea2 DM |
7 | let host = "localhost"; |
8 | let datastore = "store2"; | |
9 | ||
34aa8e13 | 10 | let auth_id = Authid::root_auth_id(); |
adec8ea2 | 11 | |
93e3581c | 12 | let options = HttpClientOptions::default() |
d59dbeca DM |
13 | .interactive(true) |
14 | .ticket_cache(true); | |
15 | ||
34aa8e13 | 16 | let client = HttpClient::new(host, 8007, auth_id, options)?; |
adec8ea2 | 17 | |
6ef1b649 | 18 | let backup_time = proxmox_time::epoch_i64(); |
ca5d0b61 | 19 | |
a22d3388 | 20 | let client = BackupWriter::start( |
fcea0794 | 21 | &client, |
a22d3388 TL |
22 | None, |
23 | datastore, | |
133d718f WB |
24 | &BackupNamespace::root(), |
25 | &(BackupType::Host, "speedtest".to_string(), backup_time).into(), | |
a22d3388 TL |
26 | false, |
27 | true, | |
28 | ) | |
29 | .await?; | |
adec8ea2 | 30 | |
32e1bf42 | 31 | println!("start upload speed test"); |
0608b36b | 32 | let res = client.upload_speedtest().await?; |
adec8ea2 DM |
33 | |
34 | Ok(res) | |
35 | } | |
36 | ||
a22d3388 | 37 | fn main() { |
9a1b24b6 | 38 | match proxmox_async::runtime::main(upload_speed()) { |
86305579 WB |
39 | Ok(mbs) => { |
40 | println!("average upload speed: {} MB/s", mbs); | |
41 | } | |
42 | Err(err) => { | |
43 | eprintln!("ERROR: {}", err); | |
adec8ea2 | 44 | } |
86305579 | 45 | } |
adec8ea2 | 46 | } |