Skip to content

Commit

Permalink
Refs #36954 - Make duration output consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
ofedoren committed Nov 29, 2023
1 parent 4cf8232 commit 61feb8d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/hammer_cli_foreman/command_extensions/ping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'] }
Expand Down
2 changes: 1 addition & 1 deletion test/functional/ping_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
'cache:',
' servers:',
' 1) Status: ok',
' Server Response: 5'
' Server Response: Duration: 5ms'
]
)

Expand Down

0 comments on commit 61feb8d

Please sign in to comment.