mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
fix 5514 - handle consecutive delimiters in hostnames while sorting them (#5515)
This commit is contained in:
parent
f3e0640a79
commit
6fc666644e
2 changed files with 3 additions and 3 deletions
|
@ -155,7 +155,7 @@ module Sidekiq
|
|||
@sorted_processes ||= begin
|
||||
return processes unless processes.all? { |p| p["hostname"] }
|
||||
|
||||
split_characters = /[._-]/
|
||||
split_characters = /[._-]+/
|
||||
|
||||
padding = processes.flat_map { |p| p["hostname"].split(split_characters) }.map(&:size).max
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ describe "Web helpers" do
|
|||
end
|
||||
|
||||
it "sorts processes using the natural sort order" do
|
||||
["a.10.2", "a.2", "busybee-10_1", "a.23", "a.10.1", "a.1", "192.168.0.10", "192.168.0.2", "2.1.1.1", "busybee-2_34"].each do |hostname|
|
||||
["a.10.2", "a.2", "busybee--10_1", "a.23", "a.10.1", "a.1", "192.168.0.10", "192.168.0.2", "2.1.1.1", "busybee-2__34"].each do |hostname|
|
||||
pdata = {"hostname" => hostname, "pid" => "123", "started_at" => Time.now.to_i}
|
||||
key = "#{hostname}:123"
|
||||
|
||||
|
@ -144,6 +144,6 @@ describe "Web helpers" do
|
|||
obj = Helpers.new
|
||||
|
||||
assert obj.sorted_processes.all? { |process| assert_instance_of Sidekiq::Process, process }
|
||||
assert_equal ["2.1.1.1", "192.168.0.2", "192.168.0.10", "a.1", "a.2", "a.10.1", "a.10.2", "a.23", "busybee-2_34", "busybee-10_1"], obj.sorted_processes.map { |process| process["hostname"] }
|
||||
assert_equal ["2.1.1.1", "192.168.0.2", "192.168.0.10", "a.1", "a.2", "a.10.1", "a.10.2", "a.23", "busybee-2__34", "busybee--10_1"], obj.sorted_processes.map { |process| process["hostname"] }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue