-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Implement 'show memory_breakdown --node [node]''
1 parent
7293ff6
commit f4390b4
Showing
8 changed files
with
241 additions
and
16 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
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,4 +1,3 @@ | ||
use crate::errors::CommandRunError; | ||
// Copyright (C) 2023-2025 RabbitMQ Core Team ([email protected]) | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
@@ -13,11 +12,12 @@ use crate::errors::CommandRunError; | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
use crate::config::SharedSettings; | ||
use crate::errors::CommandRunError; | ||
use crate::tables; | ||
use clap::ArgMatches; | ||
use rabbitmq_http_client::blocking_api::{HttpClientError, Result as ClientResult}; | ||
use rabbitmq_http_client::error::Error as ClientError; | ||
use rabbitmq_http_client::responses::Overview; | ||
use rabbitmq_http_client::responses::{NodeMemoryBreakdown, Overview}; | ||
use reqwest::StatusCode; | ||
use std::fmt; | ||
use sysexits::ExitCode; | ||
|
@@ -130,6 +130,20 @@ impl ResultHandler { | |
} | ||
} | ||
|
||
pub fn memory_breakdown_result(&mut self, result: ClientResult<NodeMemoryBreakdown>) { | ||
match result { | ||
Ok(output) => { | ||
self.exit_code = Some(ExitCode::Ok); | ||
|
||
let mut table = tables::memory_breakdown(output); | ||
self.table_styler.apply(&mut table); | ||
|
||
println!("{}", table); | ||
} | ||
Err(error) => self.report_command_run_error(&error), | ||
} | ||
} | ||
|
||
pub fn no_output_on_success<T>(&mut self, result: ClientResult<T>) { | ||
match result { | ||
Ok(_) => { | ||
|
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (C) 2023-2025 RabbitMQ Core Team ([email protected]) | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
use predicates::prelude::*; | ||
|
||
mod test_helpers; | ||
use crate::test_helpers::*; | ||
|
||
#[test] | ||
fn test_memory_breakdown_succeeds() -> Result<(), Box<dyn std::error::Error>> { | ||
let rc = api_client(); | ||
let nodes = rc.list_nodes()?; | ||
let first = nodes.get(0).unwrap(); | ||
|
||
run_succeeds(["show", "memory_breakdown", "--node", first.name.as_str()]).stdout( | ||
predicates::str::contains("Allocated but unused") | ||
.and(predicates::str::contains("Quorum queue ETS tables")) | ||
.and(predicates::str::contains("Client connections")) | ||
.and(predicates::str::contains("Metadata store")), | ||
); | ||
|
||
Ok(()) | ||
} |
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