2021-05-06 13:15:12 +02:00
|
|
|
use std::str::FromStr;
|
|
|
|
|
2022-06-11 07:24:29 +02:00
|
|
|
#[derive(Debug, Parser)]
|
2021-05-06 13:15:12 +02:00
|
|
|
struct CommonOpt {
|
2022-06-11 07:24:29 +02:00
|
|
|
#[clap(short, long)]
|
2021-05-06 13:15:12 +02:00
|
|
|
/// Enable debug logging
|
|
|
|
pub debug: bool,
|
|
|
|
}
|
|
|
|
|
2022-06-11 07:24:29 +02:00
|
|
|
#[derive(Debug, Parser)]
|
2021-05-06 13:15:12 +02:00
|
|
|
struct PreProcOpt {
|
2022-06-11 07:24:29 +02:00
|
|
|
#[clap(flatten)]
|
2021-05-06 13:15:12 +02:00
|
|
|
pub copt: CommonOpt,
|
2023-07-13 04:19:28 +02:00
|
|
|
#[clap(value_parser, short, long = "input")]
|
2021-05-06 13:15:12 +02:00
|
|
|
/// Path to unprocessed data in json format.
|
|
|
|
pub input_path: PathBuf,
|
2023-07-13 04:19:28 +02:00
|
|
|
#[clap(value_parser, short, long = "output")]
|
2021-05-06 13:15:12 +02:00
|
|
|
/// Path to write the processed output.
|
|
|
|
pub output_path: PathBuf,
|
|
|
|
}
|
|
|
|
|
2023-01-23 11:04:03 +01:00
|
|
|
#[derive(Debug, Parser)]
|
|
|
|
struct GenerateOpt {
|
|
|
|
#[clap(flatten)]
|
|
|
|
pub copt: CommonOpt,
|
2023-07-13 04:19:28 +02:00
|
|
|
#[clap(value_parser, short, long = "output")]
|
2023-01-23 11:04:03 +01:00
|
|
|
/// Path to write the generated output.
|
|
|
|
pub output_path: PathBuf,
|
|
|
|
}
|
|
|
|
|
2022-06-11 07:24:29 +02:00
|
|
|
#[derive(Debug, Parser)]
|
2021-05-06 13:15:12 +02:00
|
|
|
struct SetupOpt {
|
2022-06-11 07:24:29 +02:00
|
|
|
#[clap(flatten)]
|
2021-05-06 13:15:12 +02:00
|
|
|
pub copt: CommonOpt,
|
2022-06-11 07:24:29 +02:00
|
|
|
#[clap(name = "target")]
|
2021-05-06 13:15:12 +02:00
|
|
|
pub target: TargetOpt,
|
2023-07-13 04:19:28 +02:00
|
|
|
#[clap(value_parser, short, long = "profile")]
|
2021-05-06 13:15:12 +02:00
|
|
|
/// Path to the test profile.
|
|
|
|
pub profile_path: PathBuf,
|
|
|
|
}
|
|
|
|
|
2022-06-11 07:24:29 +02:00
|
|
|
#[derive(Debug, Parser)]
|
2021-05-06 13:15:12 +02:00
|
|
|
struct RunOpt {
|
2022-06-11 07:24:29 +02:00
|
|
|
#[clap(flatten)]
|
2021-05-06 13:15:12 +02:00
|
|
|
pub copt: CommonOpt,
|
2022-06-11 07:24:29 +02:00
|
|
|
#[clap(name = "target")]
|
2021-05-06 13:15:12 +02:00
|
|
|
pub target: TargetOpt,
|
2023-09-07 11:04:54 +02:00
|
|
|
#[clap(
|
|
|
|
name = "test-type",
|
|
|
|
help = "Which type of test to run against this system: currently supports 'search-basic'"
|
|
|
|
)]
|
2021-05-06 13:15:12 +02:00
|
|
|
/// Which type of test to run against this system
|
|
|
|
pub test_type: TestTypeOpt,
|
2023-07-13 04:19:28 +02:00
|
|
|
#[clap(value_parser, short, long = "profile")]
|
2021-05-06 13:15:12 +02:00
|
|
|
/// Path to the test profile.
|
|
|
|
pub profile_path: PathBuf,
|
|
|
|
}
|
|
|
|
|
2023-08-14 09:42:21 +02:00
|
|
|
#[derive(Debug, Parser)]
|
|
|
|
/// Configuration options
|
|
|
|
struct ConfigOpt {
|
|
|
|
#[clap(flatten)]
|
|
|
|
pub copt: CommonOpt,
|
|
|
|
#[clap(value_parser, short, long)]
|
|
|
|
/// Update the admin password
|
|
|
|
pub admin_password: Option<String>,
|
|
|
|
#[clap(value_parser, short, long)]
|
|
|
|
/// Update the Kanidm URI
|
|
|
|
pub kanidm_uri: Option<String>,
|
|
|
|
#[clap(value_parser, short, long)]
|
|
|
|
/// Update the LDAP URI
|
|
|
|
pub ldap_uri: Option<String>,
|
2023-09-07 11:04:54 +02:00
|
|
|
#[clap(value_parser, long)]
|
2023-08-14 09:42:21 +02:00
|
|
|
/// Update the LDAP base DN
|
|
|
|
pub ldap_base_dn: Option<String>,
|
|
|
|
|
|
|
|
#[clap(value_parser, short = 'D', long)]
|
|
|
|
/// Set the configuration name
|
|
|
|
pub name: Option<String>,
|
|
|
|
|
2023-09-07 11:04:54 +02:00
|
|
|
#[clap(value_parser, long)]
|
2023-08-14 09:42:21 +02:00
|
|
|
/// The data file path to update (or create)
|
|
|
|
pub data_file: Option<String>,
|
|
|
|
|
|
|
|
#[clap(value_parser, short, long)]
|
|
|
|
/// The place we'll drop the results
|
|
|
|
pub results: Option<PathBuf>,
|
|
|
|
|
|
|
|
#[clap(value_parser, short, long)]
|
|
|
|
/// The configuration file path to update (or create)
|
|
|
|
pub profile: PathBuf,
|
|
|
|
}
|
|
|
|
|
2023-07-13 04:19:28 +02:00
|
|
|
#[derive(Debug, Subcommand, Clone)]
|
2023-01-23 11:04:03 +01:00
|
|
|
/// The target to run against
|
2021-05-06 13:15:12 +02:00
|
|
|
pub(crate) enum TargetOpt {
|
2022-06-11 07:24:29 +02:00
|
|
|
#[clap(name = "ds")]
|
2021-05-06 13:15:12 +02:00
|
|
|
/// Run against the ldap/ds profile
|
|
|
|
Ds,
|
2023-01-23 11:04:03 +01:00
|
|
|
#[clap(name = "ipa")]
|
|
|
|
/// Run against the ipa profile
|
|
|
|
Ipa,
|
2022-06-11 07:24:29 +02:00
|
|
|
#[clap(name = "kanidm")]
|
2021-05-06 13:15:12 +02:00
|
|
|
/// Run against the kanidm http profile
|
|
|
|
Kanidm,
|
2023-03-02 03:47:23 +01:00
|
|
|
#[clap(name = "kanidm-ldap")]
|
2021-05-06 13:15:12 +02:00
|
|
|
/// Run against the kanidm ldap profile
|
|
|
|
KanidmLdap,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl FromStr for TargetOpt {
|
|
|
|
type Err = &'static str;
|
|
|
|
|
|
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
|
|
match s {
|
|
|
|
"ds" => Ok(TargetOpt::Ds),
|
2023-01-23 11:04:03 +01:00
|
|
|
"ipa" => Ok(TargetOpt::Ipa),
|
2021-05-06 13:15:12 +02:00
|
|
|
"kanidm" => Ok(TargetOpt::Kanidm),
|
2023-03-02 03:47:23 +01:00
|
|
|
"kanidm-ldap" => Ok(TargetOpt::KanidmLdap),
|
|
|
|
_ => Err("Invalid target type. Must be ds, ipa, kanidm, or kanidm-ldap"),
|
2021-05-06 13:15:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-13 04:19:28 +02:00
|
|
|
#[derive(Debug, Subcommand, Clone)]
|
2021-05-06 13:15:12 +02:00
|
|
|
pub(crate) enum TestTypeOpt {
|
2022-06-11 07:24:29 +02:00
|
|
|
#[clap(name = "search-basic")]
|
2021-05-06 13:15:12 +02:00
|
|
|
/// Perform a basic search-only test
|
|
|
|
SearchBasic,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl FromStr for TestTypeOpt {
|
|
|
|
type Err = &'static str;
|
|
|
|
|
|
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
|
|
match s {
|
|
|
|
"search-basic" => Ok(TestTypeOpt::SearchBasic),
|
|
|
|
_ => Err("Invalid test type."),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::fmt::Display for TestTypeOpt {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
match &self {
|
|
|
|
TestTypeOpt::SearchBasic => write!(f, "search-basic"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-11 07:24:29 +02:00
|
|
|
#[derive(Debug, Parser)]
|
|
|
|
#[clap(
|
|
|
|
name = "orca",
|
|
|
|
about = "Orca Load Testing Utility
|
2022-05-03 05:24:39 +02:00
|
|
|
|
|
|
|
Orca works in a few steps.
|
|
|
|
|
2022-05-03 05:34:23 +02:00
|
|
|
1. Create an orca config which defines the targets you want to be able to setup and load test. See example_profiles/small/orca.toml
|
|
|
|
|
|
|
|
2. (Optional) preprocess an anonymised 389-ds access log (created from an external tool) into an orca data set.
|
|
|
|
|
|
|
|
3. 'orca setup' the kanidm/389-ds instance from the orca data set. You can see an example of this in example_profiles/small/data.json. This will reset the database, and add tons of entries etc. For example:
|
|
|
|
|
|
|
|
orca setup kanidm -p ./example_profiles/small/orca.toml
|
|
|
|
|
|
|
|
4. 'orca run' one of the metrics, based on that data set. For example:
|
2022-05-03 05:24:39 +02:00
|
|
|
|
|
|
|
orca run -p example_profiles/small/orca.toml kanidm search-basic
|
|
|
|
|
2022-06-11 07:24:29 +02:00
|
|
|
"
|
|
|
|
)]
|
2021-05-06 13:15:12 +02:00
|
|
|
enum OrcaOpt {
|
2023-01-23 11:04:03 +01:00
|
|
|
#[clap(name = "conntest")]
|
|
|
|
/// Perform a connection test against the specified target
|
|
|
|
TestConnection(SetupOpt),
|
|
|
|
#[clap(name = "generate")]
|
|
|
|
/// Generate a new dataset that can be used for testing. Parameters can be provided
|
|
|
|
/// to affect the type and quantity of data created.
|
|
|
|
Generate(GenerateOpt),
|
2022-06-11 07:24:29 +02:00
|
|
|
#[clap(name = "preprocess")]
|
2021-05-06 13:15:12 +02:00
|
|
|
/// Preprocess a dataset that can be used for testing
|
|
|
|
PreProc(PreProcOpt),
|
2022-06-11 07:24:29 +02:00
|
|
|
#[clap(name = "setup")]
|
2021-05-06 13:15:12 +02:00
|
|
|
/// Setup a server as defined by a test profile
|
|
|
|
Setup(SetupOpt),
|
2022-06-11 07:24:29 +02:00
|
|
|
#[clap(name = "run")]
|
2022-05-03 05:24:39 +02:00
|
|
|
/// Run the load test as defined by the test profile
|
2021-05-06 13:15:12 +02:00
|
|
|
Run(RunOpt),
|
2023-03-01 01:10:31 +01:00
|
|
|
#[clap(name = "version")]
|
|
|
|
/// Print version info and exit
|
2023-08-14 09:42:21 +02:00
|
|
|
Version(CommonOpt),
|
|
|
|
#[clap(name = "configure")]
|
|
|
|
/// Update a config file
|
|
|
|
Configure(ConfigOpt),
|
2021-05-06 13:15:12 +02:00
|
|
|
}
|