Skip to content

Commit

Permalink
feat(client/test): expose test features
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Castro <[email protected]>
  • Loading branch information
tiagolobocastro committed Dec 8, 2023
1 parent 26c77c7 commit 6a025b9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions io-engine/src/bin/io-engine-client/v1/test_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use strum_macros::{AsRefStr, EnumString, EnumVariantNames};
use tonic::Status;

pub fn subcommands() -> Command {
let features = Command::new("features").about("Get the test features");

let inject = Command::new("inject")
.about("manage fault injections")
.arg(
Expand Down Expand Up @@ -89,6 +91,7 @@ pub fn subcommands() -> Command {
.subcommand_required(true)
.arg_required_else_help(true)
.about("Test management")
.subcommand(features)
.subcommand(inject)
.subcommand(wipe)
}
Expand Down Expand Up @@ -144,6 +147,7 @@ impl From<WipeMethod> for v1_rpc::test::wipe_options::CheckSumAlgorithm {
pub async fn handler(ctx: Context, matches: &ArgMatches) -> crate::Result<()> {
match matches.subcommand().unwrap() {
("inject", args) => injections(ctx, args).await,
("features", args) => features(ctx, args).await,
("wipe", args) => wipe(ctx, args).await,
(cmd, _) => {
Err(Status::not_found(format!("command {cmd} does not exist")))
Expand All @@ -152,6 +156,23 @@ pub async fn handler(ctx: Context, matches: &ArgMatches) -> crate::Result<()> {
}
}

async fn features(
mut ctx: Context,
_matches: &ArgMatches,
) -> crate::Result<()> {
let response = ctx.v1.test.get_features(()).await.context(GrpcStatus)?;
let features = response.into_inner();
match ctx.output {
OutputFormat::Json => {
println!("{}", serde_json::to_string_pretty(&features).unwrap());
}
OutputFormat::Default => {
println!("{features:#?}");
}
}
Ok(())
}

async fn wipe(ctx: Context, matches: &ArgMatches) -> crate::Result<()> {
let resource = matches
.get_one::<String>("resource")
Expand Down Expand Up @@ -204,6 +225,7 @@ async fn replica_wipe(
)
.map_err(|s| Status::invalid_argument(format!("Bad size '{s}'")))
.context(GrpcStatus)?;

let response = ctx
.v1
.test
Expand Down
2 changes: 1 addition & 1 deletion utils/dependencies
Submodule dependencies updated 0 files

0 comments on commit 6a025b9

Please sign in to comment.