summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-11-23 06:06:43 +0000
committerRobert Speicher <robert@gitlab.com>2016-11-23 06:06:43 +0000
commitd0c0c75ca9568bc3ec00c341a6053623d85e6201 (patch)
treed94110f64ff25f0eb170f744449d24e8906306f6
parent536ec509d57705e7e62518dfba82e5727499bc8a (diff)
parent40822b618576f06098f3f61cc5e11a29d656619e (diff)
downloadgitlab-ce-d0c0c75ca9568bc3ec00c341a6053623d85e6201.tar.gz
Merge branch 'fix_sidekiq_stats_in_admin_area' into 'master'
Fix Sidekiq stats in admin area Closes #23825, #24675 See merge request !7654
-rw-r--r--app/helpers/sidekiq_helper.rb10
-rw-r--r--changelogs/unreleased/fix_sidekiq_stats_in_admin_area.yml4
-rw-r--r--spec/helpers/sidekiq_helper_spec.rb23
3 files changed, 30 insertions, 7 deletions
diff --git a/app/helpers/sidekiq_helper.rb b/app/helpers/sidekiq_helper.rb
index 56749d80bd3..b5017080cfb 100644
--- a/app/helpers/sidekiq_helper.rb
+++ b/app/helpers/sidekiq_helper.rb
@@ -5,15 +5,11 @@ module SidekiqHelper
(?<mem>[\d\.,]+)\s+
(?<state>[DRSTWXZNLsl\+<]+)\s+
(?<start>.+)\s+
- (?<command>sidekiq.*\])\s*
+ (?<command>sidekiq.*\])
\z/x
def parse_sidekiq_ps(line)
- match = line.match(SIDEKIQ_PS_REGEXP)
- if match
- match[1..6]
- else
- %w[? ? ? ? ? ?]
- end
+ match = line.strip.match(SIDEKIQ_PS_REGEXP)
+ match ? match[1..6] : Array.new(6, '?')
end
end
diff --git a/changelogs/unreleased/fix_sidekiq_stats_in_admin_area.yml b/changelogs/unreleased/fix_sidekiq_stats_in_admin_area.yml
new file mode 100644
index 00000000000..4f007be8624
--- /dev/null
+++ b/changelogs/unreleased/fix_sidekiq_stats_in_admin_area.yml
@@ -0,0 +1,4 @@
+---
+title: Sidekiq stats in the admin area will now show correctly on different platforms
+merge_request:
+author: blackst0ne
diff --git a/spec/helpers/sidekiq_helper_spec.rb b/spec/helpers/sidekiq_helper_spec.rb
index d60839b78ec..f86e496740a 100644
--- a/spec/helpers/sidekiq_helper_spec.rb
+++ b/spec/helpers/sidekiq_helper_spec.rb
@@ -30,6 +30,29 @@ describe SidekiqHelper do
expect(parts).to eq(['55137', '10.0', '2.1', 'S+', '2:30pm', 'sidekiq 4.1.4 gitlab [0 of 25 busy]'])
end
+ it 'parses OSX output' do
+ line = ' 1641 1.5 3.8 S+ 4:04PM sidekiq 4.2.1 gitlab [0 of 25 busy]'
+ parts = helper.parse_sidekiq_ps(line)
+
+ expect(parts).to eq(['1641', '1.5', '3.8', 'S+', '4:04PM', 'sidekiq 4.2.1 gitlab [0 of 25 busy]'])
+ end
+
+ it 'parses Ubuntu output' do
+ # Ubuntu Linux 16.04 LTS / procps-3.3.10-4ubuntu2
+ line = ' 938 1.4 2.5 Sl+ 21:23:21 sidekiq 4.2.1 gitlab [0 of 25 busy] '
+ parts = helper.parse_sidekiq_ps(line)
+
+ expect(parts).to eq(['938', '1.4', '2.5', 'Sl+', '21:23:21', 'sidekiq 4.2.1 gitlab [0 of 25 busy]'])
+ end
+
+ it 'parses Debian output' do
+ # Debian Linux Wheezy/Jessie
+ line = '17725 1.0 12.1 Ssl 19:20:15 sidekiq 4.2.1 gitlab-rails [0 of 25 busy] '
+ parts = helper.parse_sidekiq_ps(line)
+
+ expect(parts).to eq(['17725', '1.0', '12.1', 'Ssl', '19:20:15', 'sidekiq 4.2.1 gitlab-rails [0 of 25 busy]'])
+ end
+
it 'does fail gracefully on line not matching the format' do
line = '55137 10.0 2.1 S+ 2:30pm something'
parts = helper.parse_sidekiq_ps(line)