From 61feb8d8b2631aca5d99099da0cb945426ae03f6 Mon Sep 17 00:00:00 2001 From: Oleh Fedorenko Date: Wed, 29 Nov 2023 14:51:38 +0000 Subject: [PATCH] Refs #36954 - Make duration output consistent --- lib/hammer_cli_foreman/command_extensions/ping.rb | 14 ++++++++++++++ test/functional/ping_test.rb | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/hammer_cli_foreman/command_extensions/ping.rb b/lib/hammer_cli_foreman/command_extensions/ping.rb index 0a6816f21..bbf41c64e 100644 --- a/lib/hammer_cli_foreman/command_extensions/ping.rb +++ b/lib/hammer_cli_foreman/command_extensions/ping.rb @@ -7,9 +7,23 @@ class Ping < HammerCLI::CommandExtensions data['results']['foreman']['database']['active'] = status ? 'ok' : 'FAIL' duration = data['results']['foreman']['database']['duration_ms'] data['results']['foreman']['database']['duration_ms'] = _('Duration: %sms') % duration + cache = data['results']['foreman']['cache'] + data['results']['foreman']['cache'] = format_cache(cache) if cache end end + def self.format_cache(cache) + servers = cache['servers'].map do |server| + { + status: server['status'], + duration_ms: _('Duration: %sms') % server['duration_ms'] + } + end + { + 'servers': servers + } + end + def self.check_for_unrecognized(plugins, output_definition) failed = plugins.select { |_, data| data['services'] } .each_with_object([]) { |(_, d), s| s << d['services'] } diff --git a/test/functional/ping_test.rb b/test/functional/ping_test.rb index 2c991b846..c551229ee 100644 --- a/test/functional/ping_test.rb +++ b/test/functional/ping_test.rb @@ -49,7 +49,7 @@ 'cache:', ' servers:', ' 1) Status: ok', - ' Server Response: 5' + ' Server Response: Duration: 5ms' ] )