1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

return obvious fake info when INFO is disabled

This commit is contained in:
lukas 2016-02-26 00:18:46 +01:00
parent 23c1c6bcde
commit b787ed2b12
2 changed files with 20 additions and 7 deletions

View file

@ -37,6 +37,14 @@ module Sidekiq
'queue' => 'default' 'queue' => 'default'
} }
FAKE_INFO = {
"redis_version" => "9.9.9",
"uptime_in_days" => "9999",
"connected_clients" => "9999",
"used_memory_human" => "9P",
"used_memory_peak_human" => "9P"
}.freeze
def self.°° def self.°°
puts "Calm down, yo." puts "Calm down, yo."
end end
@ -92,12 +100,18 @@ module Sidekiq
def self.redis_info def self.redis_info
redis do |conn| redis do |conn|
# admin commands can't go through redis-namespace starting begin
# in redis-namespace 2.0 # admin commands can't go through redis-namespace starting
if conn.respond_to?(:namespace) # in redis-namespace 2.0
conn.redis.info if conn.respond_to?(:namespace)
else conn.redis.info
conn.info else
conn.info
end
rescue Redis::CommandError => ex
#2850 return fake version when INFO command has (probably) been renamed
raise unless ex.message =~ /unknown command/
FAKE_INFO
end end
end end
end end

View file

@ -101,7 +101,6 @@ class TestSidekiq < Sidekiq::Test
it 'calls the INFO command which returns at least redis_version' do it 'calls the INFO command which returns at least redis_version' do
output = Sidekiq.redis_info output = Sidekiq.redis_info
assert_includes output.keys, "redis_version" assert_includes output.keys, "redis_version"
assert_includes output.keys, "uptime_in_days"
end end
end end
end end