Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
67d49463
Commit
67d49463
authored
Jan 22, 2018
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ruby sampler spec
parent
938d9ffe
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb
spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb
+10
-12
No files found.
spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb
View file @
67d49463
...
@@ -2,6 +2,11 @@ require 'spec_helper'
...
@@ -2,6 +2,11 @@ require 'spec_helper'
describe
Gitlab
::
Metrics
::
Samplers
::
RubySampler
do
describe
Gitlab
::
Metrics
::
Samplers
::
RubySampler
do
let
(
:sampler
)
{
described_class
.
new
(
5
)
}
let
(
:sampler
)
{
described_class
.
new
(
5
)
}
let
(
:null_metric
)
{
double
(
'null_metric'
,
set:
nil
,
observe:
nil
)
}
before
do
allow
(
Gitlab
::
Metrics
::
NullMetric
).
to
receive
(
:instance
).
and_return
(
null_metric
)
end
after
do
after
do
Allocations
.
stop
if
Gitlab
::
Metrics
.
mri?
Allocations
.
stop
if
Gitlab
::
Metrics
.
mri?
...
@@ -17,12 +22,9 @@ describe Gitlab::Metrics::Samplers::RubySampler do
...
@@ -17,12 +22,9 @@ describe Gitlab::Metrics::Samplers::RubySampler do
end
end
it
'adds a metric containing the memory usage'
do
it
'adds a metric containing the memory usage'
do
expect
(
Gitlab
::
Metrics
::
System
).
to
receive
(
:memory_usage
)
expect
(
Gitlab
::
Metrics
::
System
).
to
receive
(
:memory_usage
).
and_return
(
9000
)
.
and_return
(
9000
)
expect
(
sampler
.
metrics
[
:memory_usage
]).
to
receive
(
:set
)
expect
(
sampler
.
metrics
[
:memory_usage
]).
to
receive
(
:set
).
with
({},
9000
)
.
with
({},
9000
)
.
and_call_original
sampler
.
sample
sampler
.
sample
end
end
...
@@ -31,9 +33,7 @@ describe Gitlab::Metrics::Samplers::RubySampler do
...
@@ -31,9 +33,7 @@ describe Gitlab::Metrics::Samplers::RubySampler do
expect
(
Gitlab
::
Metrics
::
System
).
to
receive
(
:file_descriptor_count
)
expect
(
Gitlab
::
Metrics
::
System
).
to
receive
(
:file_descriptor_count
)
.
and_return
(
4
)
.
and_return
(
4
)
expect
(
sampler
.
metrics
[
:file_descriptors
]).
to
receive
(
:set
)
expect
(
sampler
.
metrics
[
:file_descriptors
]).
to
receive
(
:set
).
with
({},
4
)
.
with
({},
4
)
.
and_call_original
sampler
.
sample
sampler
.
sample
end
end
...
@@ -49,16 +49,14 @@ describe Gitlab::Metrics::Samplers::RubySampler do
...
@@ -49,16 +49,14 @@ describe Gitlab::Metrics::Samplers::RubySampler do
it
'adds a metric containing garbage collection time statistics'
do
it
'adds a metric containing garbage collection time statistics'
do
expect
(
GC
::
Profiler
).
to
receive
(
:total_time
).
and_return
(
0.24
)
expect
(
GC
::
Profiler
).
to
receive
(
:total_time
).
and_return
(
0.24
)
expect
(
sampler
.
metrics
[
:total_time
]).
to
receive
(
:set
)
expect
(
sampler
.
metrics
[
:total_time
]).
to
receive
(
:set
).
with
({},
240
)
.
with
({},
240
)
.
and_call_original
sampler
.
sample
sampler
.
sample
end
end
it
'adds a metric containing garbage collection statistics'
do
it
'adds a metric containing garbage collection statistics'
do
GC
.
stat
.
keys
.
each
do
|
key
|
GC
.
stat
.
keys
.
each
do
|
key
|
expect
(
sampler
.
metrics
[
key
]).
to
receive
(
:set
).
with
({},
anything
)
.
and_call_original
expect
(
sampler
.
metrics
[
key
]).
to
receive
(
:set
).
with
({},
anything
)
end
end
sampler
.
sample
sampler
.
sample
...
...
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