-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for generic clients (#49)
* wip. parsing of generic arguments is weird and not working * fixed arg parsing. next add shred_version and other validator ENV variables * finish up generic client * address comments: update client trait, propagate errors up
- Loading branch information
1 parent
2c1566b
commit 978c446
Showing
11 changed files
with
638 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,117 @@ | ||
use solana_sdk::pubkey::Pubkey; | ||
use { | ||
solana_sdk::pubkey::Pubkey, | ||
std::{error::Error, path::PathBuf}, | ||
strum_macros::Display, | ||
}; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct ClientConfig { | ||
#[derive(Clone, PartialEq, Debug)] | ||
pub struct BenchTpsConfig { | ||
pub num_clients: usize, | ||
pub client_duration_seconds: u64, | ||
pub client_type: String, | ||
pub client_to_run: String, | ||
pub bench_tps_args: Vec<String>, | ||
pub client_wait_for_n_nodes: Option<usize>, | ||
pub client_to_run: String, | ||
pub client_target_node: Option<Pubkey>, | ||
} | ||
|
||
impl ClientTrait for BenchTpsConfig { | ||
fn executable_path(&self) -> Result<Vec<String>, Box<dyn Error>> { | ||
let command = vec!["/home/solana/k8s-cluster-scripts/client-startup-script.sh".to_string()]; | ||
Ok(command) | ||
} | ||
|
||
fn generate_client_command_flags(&self) -> Vec<String> { | ||
let mut flags = vec![]; | ||
|
||
flags.push(self.client_to_run.clone()); //client to run | ||
if !self.bench_tps_args.is_empty() { | ||
flags.push(self.bench_tps_args.join(" ")); | ||
} | ||
|
||
flags.push(self.client_type.clone()); | ||
|
||
if let Some(target_node) = self.client_target_node { | ||
flags.push("--target-node".to_string()); | ||
flags.push(target_node.to_string()); | ||
} | ||
|
||
flags.push("--duration".to_string()); | ||
flags.push(self.client_duration_seconds.to_string()); | ||
|
||
if let Some(num_nodes) = self.client_wait_for_n_nodes { | ||
flags.push("--num-nodes".to_string()); | ||
flags.push(num_nodes.to_string()); | ||
} | ||
|
||
flags | ||
} | ||
} | ||
|
||
#[derive(Default, Clone, PartialEq, Debug)] | ||
pub struct GenericClientConfig { | ||
pub num_clients: usize, | ||
pub client_duration_seconds: u64, | ||
pub client_wait_for_n_nodes: Option<u64>, | ||
pub args: Vec<String>, | ||
pub image: String, | ||
pub executable_path: PathBuf, | ||
pub delay_start: u64, | ||
} | ||
|
||
impl ClientTrait for GenericClientConfig { | ||
fn executable_path(&self) -> Result<Vec<String>, Box<dyn Error>> { | ||
let exec_path_string = self | ||
.executable_path | ||
.clone() | ||
.into_os_string() | ||
.into_string() | ||
.map_err(|err| { | ||
std::io::Error::new( | ||
std::io::ErrorKind::InvalidData, | ||
format!("Invalid Unicode data in path: {:?}", err), | ||
) | ||
})?; | ||
Ok(vec![exec_path_string]) | ||
} | ||
fn generate_client_command_flags(&self) -> Vec<String> { | ||
self.args.clone() | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Display)] | ||
pub enum ClientConfig { | ||
#[strum(serialize = "bench-tps")] | ||
BenchTps(BenchTpsConfig), | ||
#[strum(serialize = "generic")] | ||
Generic(GenericClientConfig), | ||
None, | ||
} | ||
|
||
impl ClientConfig { | ||
pub fn num_clients(&self) -> usize { | ||
match self { | ||
ClientConfig::BenchTps(config) => config.num_clients, | ||
ClientConfig::Generic(config) => config.num_clients, | ||
ClientConfig::None => 0, | ||
} | ||
} | ||
|
||
pub fn build_command(&self) -> Result<Vec<String>, Box<dyn Error>> { | ||
match self { | ||
ClientConfig::BenchTps(config) => config.build_command(), | ||
ClientConfig::Generic(config) => config.build_command(), | ||
ClientConfig::None => Err("Client config is None".into()), | ||
} | ||
} | ||
} | ||
|
||
pub trait ClientTrait { | ||
fn executable_path(&self) -> Result<Vec<String>, Box<dyn Error>>; | ||
fn generate_client_command_flags(&self) -> Vec<String>; | ||
/// Build command to run on pod deployment | ||
fn build_command(&self) -> Result<Vec<String>, Box<dyn Error>> { | ||
let mut command = self.executable_path()?; | ||
command.extend(self.generate_client_command_flags()); | ||
Ok(command) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.