BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
1112b5a2
Commit
1112b5a2
authored
Sep 06, 2016
by
Pascal Betz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move parsing of sidekiq ps into helper
parent
80e575af
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
8 deletions
+50
-8
sidekiq_helper.rb
app/helpers/sidekiq_helper.rb
+12
-0
show.html.haml
app/views/admin/background_jobs/show.html.haml
+3
-8
sidekiq_helper_spec.rb
spec/helpers/sidekiq_helper_spec.rb
+35
-0
No files found.
app/helpers/sidekiq_helper.rb
0 → 100644
View file @
1112b5a2
module
SidekiqHelper
SIDEKIQ_PS_REGEXP
=
/\A([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+(.+)\s+(sidekiq.*\])\s+\z/
def
parse_sidekiq_ps
(
line
)
match
=
line
.
match
(
SIDEKIQ_PS_REGEXP
)
if
match
match
[
1
..
6
]
else
%w{? ? ? ? ? ?}
end
end
end
app/views/admin/background_jobs/show.html.haml
View file @
1112b5a2
...
@@ -28,14 +28,9 @@
...
@@ -28,14 +28,9 @@
%th
COMMAND
%th
COMMAND
%tbody
%tbody
-
@sidekiq_processes
.
each
do
|
process
|
-
@sidekiq_processes
.
each
do
|
process
|
-
next
unless
process
.
match
(
/(sidekiq \d+\.\d+\.\d+.+$)/
)
%td
=
gitlab_config
.
user
-
data
=
process
.
strip
.
split
(
' '
)
-
parse_sidekiq_ps
(
process
).
each
do
|
value
|
%tr
%td
=
value
%td
=
gitlab_config
.
user
-
5
.
times
do
%td
=
data
.
shift
%td
=
data
.
join
(
' '
)
.clearfix
.clearfix
%p
%p
%i
.fa.fa-exclamation-circle
%i
.fa.fa-exclamation-circle
...
...
spec/helpers/sidekiq_helper_spec.rb
0 → 100644
View file @
1112b5a2
require
'spec_helper'
describe
SidekiqHelper
do
describe
'parse_sidekiq_ps'
do
it
'parses line with time'
do
line
=
'55137 10,0 2,1 S+ 2:30pm sidekiq 4.1.4 gitlab [0 of 25 busy] '
parts
=
helper
.
parse_sidekiq_ps
(
line
)
expect
(
parts
).
to
eq
([
'55137'
,
'10,0'
,
'2,1'
,
'S+'
,
'2:30pm'
,
'sidekiq 4.1.4 gitlab [0 of 25 busy]'
])
end
it
'parses line with date'
do
line
=
'55137 10,0 2,1 S+ Aug 4 sidekiq 4.1.4 gitlab [0 of 25 busy] '
parts
=
helper
.
parse_sidekiq_ps
(
line
)
expect
(
parts
).
to
eq
([
'55137'
,
'10,0'
,
'2,1'
,
'S+'
,
'Aug 4'
,
'sidekiq 4.1.4 gitlab [0 of 25 busy]'
])
end
it
'parses line with two digit date'
do
line
=
'55137 10,0 2,1 S+ Aug 04 sidekiq 4.1.4 gitlab [0 of 25 busy] '
parts
=
helper
.
parse_sidekiq_ps
(
line
)
expect
(
parts
).
to
eq
([
'55137'
,
'10,0'
,
'2,1'
,
'S+'
,
'Aug 04'
,
'sidekiq 4.1.4 gitlab [0 of 25 busy]'
])
end
it
'parses line with dot as float separator'
do
line
=
'55137 10.0 2.1 S+ 2:30pm sidekiq 4.1.4 gitlab [0 of 25 busy] '
parts
=
helper
.
parse_sidekiq_ps
(
line
)
expect
(
parts
).
to
eq
([
'55137'
,
'10.0'
,
'2.1'
,
'S+'
,
'2:30pm'
,
'sidekiq 4.1.4 gitlab [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
)
expect
(
parts
).
to
eq
([
'?'
,
'?'
,
'?'
,
'?'
,
'?'
,
'?'
])
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment