Skip to content

Commit 56f7bb8

Browse files
Expose two more node-specific commands under 'nodes'
1 parent cf1153f commit 56f7bb8

File tree

5 files changed

+97
-11
lines changed

5 files changed

+97
-11
lines changed

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44

55
### Enhancements
66

7-
* `vhosts` is a new command group that aggregates all the existing
8-
commands directly related to virtual hosts: `list vhosts`, `declare vhost`, `delete vhost`
7+
* `vhosts` is a new command group for operations on virtual hosts
8+
* `nodes` is a new command group for operations on nodes
99

10-
* `nodes` is a new command group for operations on nodes: `nodes list`
10+
### Bug Fixes
11+
12+
* Both `-h` and `--help` now display relevant doc guide URLs.
13+
Previously it was only the case for `--help`.
1114

1215

1316
## v2.0.0 (Mar 31, 2024)

src/cli.rs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,15 +1591,46 @@ pub fn deprecated_features_subcommands(pre_flight_settings: PreFlightSettings) -
15911591
.map(|cmd| cmd.infer_long_args(pre_flight_settings.infer_long_options))
15921592
}
15931593

1594-
pub fn nodes_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 1] {
1594+
pub fn nodes_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 3] {
15951595
let list_cmd = Command::new("list")
15961596
.long_about("Lists cluster nodes")
15971597
.after_help(color_print::cformat!(
15981598
"<bold>Doc guide</bold>: {}",
15991599
CLUSTERING_GUIDE_URL
16001600
));
16011601

1602-
[list_cmd].map(|cmd| cmd.infer_long_args(pre_flight_settings.infer_long_options))
1602+
let memory_breakdown_in_bytes_cmd = Command::new("memory_breakdown_in_bytes")
1603+
.about("Provides a memory footprint breakdown (in bytes) for the target node")
1604+
.arg(
1605+
Arg::new("node")
1606+
.long("node")
1607+
.help("target node, must be a cluster member")
1608+
.required(true),
1609+
)
1610+
.after_help(color_print::cformat!(
1611+
"<bold>Doc guide:</bold>: {}",
1612+
MEMORY_FOOTPRINT_GUIDE_URL
1613+
));
1614+
1615+
let memory_breakdown_in_percent_cmd = Command::new("memory_breakdown_in_percent")
1616+
.about("Provides a memory footprint breakdown (in percent) for the target node")
1617+
.arg(
1618+
Arg::new("node")
1619+
.long("node")
1620+
.help("target node, must be a cluster member")
1621+
.required(true),
1622+
)
1623+
.after_help(color_print::cformat!(
1624+
"<bold>Doc guide:</bold>: {}",
1625+
MEMORY_FOOTPRINT_GUIDE_URL
1626+
));
1627+
1628+
[
1629+
list_cmd,
1630+
memory_breakdown_in_percent_cmd,
1631+
memory_breakdown_in_bytes_cmd,
1632+
]
1633+
.map(|cmd| cmd.infer_long_args(pre_flight_settings.infer_long_options))
16031634
}
16041635

16051636
pub fn vhosts_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 3] {

src/main.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,14 @@ fn dispatch_common_subcommand(
291291
println!("Using endpoint: {}", endpoint);
292292
res_handler.no_output_on_success(Ok(()))
293293
}
294-
("show", "memory_breakdown_in_bytes") => {
295-
let result = commands::show_memory_breakdown(client, second_level_args);
296-
res_handler.memory_breakdown_in_bytes_result(result)
297-
}
298294
("show", "memory_breakdown_in_percent") => {
299295
let result = commands::show_memory_breakdown(client, second_level_args);
300296
res_handler.memory_breakdown_in_percent_result(result)
301297
}
298+
("show", "memory_breakdown_in_bytes") => {
299+
let result = commands::show_memory_breakdown(client, second_level_args);
300+
res_handler.memory_breakdown_in_bytes_result(result)
301+
}
302302

303303
("list", "nodes") => {
304304
let result = commands::list_nodes(client);
@@ -492,6 +492,14 @@ fn dispatch_common_subcommand(
492492
let result = commands::list_nodes(client);
493493
res_handler.tabular_result(result)
494494
}
495+
("nodes", "memory_breakdown_in_percent") => {
496+
let result = commands::show_memory_breakdown(client, second_level_args);
497+
res_handler.memory_breakdown_in_percent_result(result)
498+
}
499+
("nodes", "memory_breakdown_in_bytes") => {
500+
let result = commands::show_memory_breakdown(client, second_level_args);
501+
res_handler.memory_breakdown_in_bytes_result(result)
502+
}
495503
("purge", "queue") => {
496504
let result = commands::purge_queue(client, &vhost, second_level_args);
497505
res_handler.no_output_on_success(result);

tests/memory_breakdown_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod test_helpers;
1717
use crate::test_helpers::*;
1818

1919
#[test]
20-
fn test_memory_breakdown_in_bytes_succeeds() -> Result<(), Box<dyn std::error::Error>> {
20+
fn test_show_memory_breakdown_in_bytes_succeeds() -> Result<(), Box<dyn std::error::Error>> {
2121
let rc = api_client();
2222
let nodes = rc.list_nodes()?;
2323
let first = nodes.first().unwrap();
@@ -39,7 +39,7 @@ fn test_memory_breakdown_in_bytes_succeeds() -> Result<(), Box<dyn std::error::E
3939
}
4040

4141
#[test]
42-
fn test_memory_breakdown_in_percent_succeeds() -> Result<(), Box<dyn std::error::Error>> {
42+
fn test_show_memory_breakdown_in_percent_succeeds() -> Result<(), Box<dyn std::error::Error>> {
4343
let rc = api_client();
4444
let nodes = rc.list_nodes()?;
4545
let first = nodes.first().unwrap();

tests/nodes_tests.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,47 @@ fn test_list_nodes() -> Result<(), Box<dyn std::error::Error>> {
2424

2525
Ok(())
2626
}
27+
28+
#[test]
29+
fn test_nodes_memory_breakdown_in_bytes_succeeds() -> Result<(), Box<dyn std::error::Error>> {
30+
let rc = api_client();
31+
let nodes = rc.list_nodes()?;
32+
let first = nodes.first().unwrap();
33+
34+
run_succeeds([
35+
"nodes",
36+
"memory_breakdown_in_bytes",
37+
"--node",
38+
first.name.as_str(),
39+
])
40+
.stdout(
41+
predicates::str::contains("Allocated but unused")
42+
.and(predicates::str::contains("Quorum queue ETS tables"))
43+
.and(predicates::str::contains("Client connections"))
44+
.and(predicates::str::contains("Metadata store")),
45+
);
46+
47+
Ok(())
48+
}
49+
50+
#[test]
51+
fn test_nodes_memory_breakdown_in_percent_succeeds() -> Result<(), Box<dyn std::error::Error>> {
52+
let rc = api_client();
53+
let nodes = rc.list_nodes()?;
54+
let first = nodes.first().unwrap();
55+
56+
run_succeeds([
57+
"nodes",
58+
"memory_breakdown_in_bytes",
59+
"--node",
60+
first.name.as_str(),
61+
])
62+
.stdout(
63+
predicates::str::contains("Allocated but unused")
64+
.and(predicates::str::contains("Quorum queue ETS tables"))
65+
.and(predicates::str::contains("Client connections"))
66+
.and(predicates::str::contains("Metadata store")),
67+
);
68+
69+
Ok(())
70+
}

0 commit comments

Comments
 (0)