Added the scaffolding for the jitter test. Now just need to perform the proper calculations.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Gregory Ballantine 2022-08-17 18:39:53 -04:00
parent 7555a2a3a7
commit 88be1ad2ba
2 changed files with 45 additions and 8 deletions

View File

@ -25,6 +25,28 @@ pub fn ping_host(address: &str, count: &u16) {
} }
} }
// network jitter test
pub fn jitter_test(address: &str, count: &u16) {
println!("Pinging host {}, {} times to determine network jitter.", address, count);
// run the ping command
let output = process::Command::new("ping")
.arg(address)
.arg(format!("-c {}", count))
.output()
.expect("Failed to execute command");
// check that the command succeeded
assert!(output.status.success());
// grab the ping results from stdout
let results_raw = &String::from_utf8_lossy(&output.stdout);
let results = text::format::trim_output(results_raw, 4);
for line in results {
println!("{}", line);
}
}
// timed file copy test to guage bandwidth speeds // timed file copy test to guage bandwidth speeds
pub fn bandwidth_test(download: &str, output: &str) { pub fn bandwidth_test(download: &str, output: &str) {
println!("Testing network bandwidth by downloading {}.", download); println!("Testing network bandwidth by downloading {}.", download);

View File

@ -11,8 +11,8 @@ struct Cli {
#[clap(subcommand)] #[clap(subcommand)]
command: Commands, command: Commands,
#[clap(short = 'l', long, default_value_t = 1, help = "Number of times to run test. Default = 1", global = true)] #[clap(short = 'i', long, default_value_t = 1, help = "Number of times to run test. Default = 1", global = true)]
loopcount: u8, iterations: u8,
} }
#[derive(Subcommand)] #[derive(Subcommand)]
@ -108,6 +108,15 @@ enum NetCommands {
count: u16, count: u16,
}, },
// jitter subcommand
#[clap(name = "jitter", about = "Ping a host to determine network jitter.")]
Jitter {
#[clap(short = 'a', long, default_value_t = String::from("8.8.8.8"))]
address: String,
#[clap(short = 'c', long, default_value_t = 30)]
count: u16,
},
// bandwidth test subcommand // bandwidth test subcommand
#[clap(name = "bandwidth", about = "Downloads a remote file to determine network bandwidth.")] #[clap(name = "bandwidth", about = "Downloads a remote file to determine network bandwidth.")]
Bandwidth { Bandwidth {
@ -129,25 +138,25 @@ fn main() {
Commands::Disk(args) => match &args.disk_commands { Commands::Disk(args) => match &args.disk_commands {
DiskCommands::ReadSeqTest { tempfile, size } => { DiskCommands::ReadSeqTest { tempfile, size } => {
for i in 0..cli.loopcount { for i in 0..cli.iterations {
println!("Test run number {}.", i + 1); println!("Test run number {}.", i + 1);
benchmarks::disk::disk_read_seq_test(tempfile, size); benchmarks::disk::disk_read_seq_test(tempfile, size);
} }
}, },
DiskCommands::ReadRandTest { tempfile, size } => { DiskCommands::ReadRandTest { tempfile, size } => {
for i in 0..cli.loopcount { for i in 0..cli.iterations {
println!("Test run number {}.", i + 1); println!("Test run number {}.", i + 1);
benchmarks::disk::disk_read_rand_test(tempfile, size); benchmarks::disk::disk_read_rand_test(tempfile, size);
} }
}, },
DiskCommands::WriteSeqTest { tempfile, size } => { DiskCommands::WriteSeqTest { tempfile, size } => {
for i in 0..cli.loopcount { for i in 0..cli.iterations {
println!("Test run number {}.", i + 1); println!("Test run number {}.", i + 1);
benchmarks::disk::disk_write_seq_test(tempfile, size); benchmarks::disk::disk_write_seq_test(tempfile, size);
} }
}, },
DiskCommands::WriteRandTest { tempfile, size } => { DiskCommands::WriteRandTest { tempfile, size } => {
for i in 0..cli.loopcount { for i in 0..cli.iterations {
println!("Test run number {}.", i + 1); println!("Test run number {}.", i + 1);
benchmarks::disk::disk_write_rand_test(tempfile, size); benchmarks::disk::disk_write_rand_test(tempfile, size);
} }
@ -156,13 +165,19 @@ fn main() {
Commands::Net(args) => match &args.net_commands { Commands::Net(args) => match &args.net_commands {
NetCommands::Ping { address, count } => { NetCommands::Ping { address, count } => {
for i in 0..cli.loopcount { for i in 0..cli.iterations {
println!("Test run number {}.", i + 1); println!("Test run number {}.", i + 1);
benchmarks::network::ping_host(address, count); benchmarks::network::ping_host(address, count);
} }
}, },
NetCommands::Jitter { address, count } => {
for i in 0..cli.iterations {
println!("Test run number {}.", i + 1);
benchmarks::network::jitter_test(address, count);
}
},
NetCommands::Bandwidth { download, output } => { NetCommands::Bandwidth { download, output } => {
for i in 0..cli.loopcount { for i in 0..cli.iterations {
println!("Test run number {}.", i + 1); println!("Test run number {}.", i + 1);
benchmarks::network::bandwidth_test(download, output); benchmarks::network::bandwidth_test(download, output);
} }