Skip to content

Commit

Permalink
New command group: 'deprecated_features'
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Dec 29, 2024
1 parent 348760e commit b2cf0ed
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 3 deletions.
31 changes: 30 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,39 @@
# rabbitmqadmin-ng Change Log

## v0.16.0 (in development)
## v0.17.0 (in development)

No (documented) changes yet.


## v0.16.0 (Dec 29, 2024)

### Enhancements

* `rabbitmqadmin feature_flags list` (also available as `rabbitmqadmin list feature_flags`) is a new command
that lists feature flags and their cluster state.

GitHub issue: [#38](https://github.com/rabbitmq/rabbitmqadmin-ng/issues/38)

* `rabbitmqadmin feature_flags enable --name {feature flag}` and `rabbitmqadmin feature_flags enable_all` are new commands
that enable feature flags.

Just like its `rabbitmqctl` counterpart, `rabbitmqadmin feature_flags enable_all` will only enable
the stable feature flags and will skip the experimental ones.

GitHub issues: [#41](https://github.com/rabbitmq/rabbitmqadmin-ng/issues/41)

* `rabbitmqadmin deprecated_features list` (also available as `rabbitmqadmin list deprecated_features`) is a new
function that lists all [deprecated features](https://www.rabbitmq.com/docs/deprecated-features).

GitHub issue: [#39](https://github.com/rabbitmq/rabbitmqadmin-ng/issues/39)

* `rabbitmqadmin deprecated_features list_used` (also available as `rabbitmqadmin list deprecated_features_in_use`) is a new
function that lists the [deprecated features](https://www.rabbitmq.com/docs/deprecated-features) that are found to be
used in the cluster.

GitHub issue: [#40](https://github.com/rabbitmq/rabbitmqadmin-ng/issues/40)


## v0.15.0 (Dec 26, 2024)

### Enhancements
Expand Down
28 changes: 27 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub fn parser() -> Command {
.short('p')
.long("password")
.requires("username")
.help("must be specified if --username is used"),
.help("requires username to be specified via --username or in the config file"),
)
// --insecure
.arg(
Expand Down Expand Up @@ -248,6 +248,14 @@ pub fn parser() -> Command {
))
.subcommand_value_name("feature flag")
.subcommands(feature_flags_subcommands()),
Command::new("deprecated_features")
.about("operations on deprecated features")
.after_long_help(color_print::cformat!(
"<bold>Doc guide</bold>: {}",
DEPRECATED_FEATURE_GUIDE_URL
))
.subcommand_value_name("deprecated feature")
.subcommands(deprecated_features_subcommands()),
Command::new("publish")
.about(color_print::cstr!("Publishes (<red>inefficiently</red>) message(s) to a queue or a stream. <bold><red>Only suitable for development and test environments</red></bold>."))
.after_long_help(color_print::cformat!("<bold>Doc guide</bold>: {}", PUBLISHER_GUIDE_URL))
Expand Down Expand Up @@ -1042,6 +1050,24 @@ pub fn feature_flags_subcommands() -> [Command; 3] {
[list_cmd, enable_cmd, enable_all_cmd]
}

pub fn deprecated_features_subcommands() -> [Command; 2] {
let list_cmd = Command::new("list")
.long_about("Lists deprecated features")
.after_long_help(color_print::cformat!(
"<bold>Doc guide</bold>: {}",
DEPRECATED_FEATURE_GUIDE_URL
));

let list_in_use_cmd = Command::new("list_used")
.long_about("Lists the deprecated features that are found to be in use in the cluster")
.after_long_help(color_print::cformat!(
"<bold>Doc guide</bold>: {}",
DEPRECATED_FEATURE_GUIDE_URL
));

[list_cmd, list_in_use_cmd]
}

pub fn publish_subcommands() -> [Command; 1] {
[Command::new("message")
.about("Publishes a message to an exchange")
Expand Down
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,14 @@ fn dispatch_subcommand(
let result = commands::enable_all_stable_feature_flags(client);
res_handler.no_output_on_success(result);
}
("deprecated_features", "list") => {
let result = commands::list_deprecated_features(client);
res_handler.tabular_result(result.map(|val| val.0))
}
("deprecated_features", "list_used") => {
let result = commands::list_deprecated_features_in_use(client);
res_handler.tabular_result(result.map(|val| val.0))
}
("publish", "message") => {
let result = commands::publish_message(client, &vhost, command_args);
res_handler.single_value_result(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::test_helpers::*;

#[test]
fn test_list_all_deprecated_features() -> Result<(), Box<dyn std::error::Error>> {
run_succeeds(["list", "deprecated_features"]).stdout(predicate::str::contains("ram_node_type"));
run_succeeds(["deprecated_features", "list"]).stdout(predicate::str::contains("ram_node_type"));

Ok(())
}
Expand All @@ -31,6 +31,49 @@ fn test_list_deprecated_features_in_use() -> Result<(), Box<dyn std::error::Erro

delete_vhost(vh).expect("failed to delete a virtual host");

// there are no deprecated features in use at this point
run_succeeds(["deprecated_features", "list_used"])
.stdout(predicate::str::contains("transient_nonexcl_queues").not());

run_succeeds(["declare", "vhost", "--name", vh]);
run_succeeds([
"-V",
vh,
"declare",
"queue",
"--name",
q,
"--type",
"classic",
"--durable",
"false",
]);

await_queue_metric_emission();

// now there is: a non-exclusive transient queue
run_succeeds(["list", "deprecated_features_in_use"])
.stdout(predicate::str::contains("transient_nonexcl_queues"));

delete_vhost(vh).expect("failed to delete a virtual host");

Ok(())
}

#[test]
fn test_list_all_deprecated_features_via_alias() -> Result<(), Box<dyn std::error::Error>> {
run_succeeds(["list", "deprecated_features"]).stdout(predicate::str::contains("ram_node_type"));

Ok(())
}

#[test]
fn test_list_deprecated_features_in_use_via_alias() -> Result<(), Box<dyn std::error::Error>> {
let vh = "test_list_deprecated_features_in_use_via_alias";
let q = "test_list_deprecated_features_in_use_via_alias.cq.transient.1";

delete_vhost(vh).expect("failed to delete a virtual host");

// there are no deprecated features in use at this point
run_succeeds(["list", "deprecated_features_in_use"])
.stdout(predicate::str::contains("transient_nonexcl_queues").not());
Expand Down

0 comments on commit b2cf0ed

Please sign in to comment.