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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
c79e8418
Commit
c79e8418
authored
Apr 05, 2022
by
Piotr Skorupa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change UsageDataQueries calls to be deterministic
parent
96a8605e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
9 deletions
+36
-9
ee/spec/lib/ee/gitlab/usage/service_ping_report_spec.rb
ee/spec/lib/ee/gitlab/usage/service_ping_report_spec.rb
+20
-0
lib/gitlab/usage_data_queries.rb
lib/gitlab/usage_data_queries.rb
+10
-3
spec/lib/gitlab/usage_data_queries_spec.rb
spec/lib/gitlab/usage_data_queries_spec.rb
+6
-6
No files found.
ee/spec/lib/ee/gitlab/usage/service_ping_report_spec.rb
View file @
c79e8418
...
...
@@ -23,4 +23,24 @@ RSpec.describe Gitlab::Usage::ServicePingReport, :use_clean_rails_memory_store_c
expect
{
described_class
.
for
(
output: :all_metrics_values
)
}.
not_to
raise_error
end
end
context
'for output: :metrics_queries'
do
before
do
stub_usage_data_connections
stub_object_store_settings
stub_prometheus_queries
end
it
'returns queries that do not change between calls'
do
report
=
Timecop
.
freeze
(
2021
,
1
,
1
)
do
described_class
.
for
(
output: :metrics_queries
)
end
other_report
=
Timecop
.
freeze
(
2021
,
1
,
1
)
do
described_class
.
for
(
output: :metrics_queries
)
end
expect
(
report
).
to
eq
(
other_report
)
end
end
end
lib/gitlab/usage_data_queries.rb
View file @
c79e8418
...
...
@@ -50,7 +50,7 @@ module Gitlab
def
alt_usage_data
(
value
=
nil
,
fallback:
FALLBACK
,
&
block
)
if
block_given?
{
alt_usage_data_block:
block
.
to_s
}
{
alt_usage_data_block:
"non-SQL usage data block"
}
else
{
alt_usage_data_value:
value
}
end
...
...
@@ -58,9 +58,9 @@ module Gitlab
def
redis_usage_data
(
counter
=
nil
,
&
block
)
if
block_given?
{
redis_usage_data_block:
block
.
to_s
}
{
redis_usage_data_block:
"non-SQL usage data block"
}
elsif
counter
.
present?
{
redis_usage_data_counter:
counter
}
{
redis_usage_data_counter:
counter
.
to_s
}
end
end
...
...
@@ -74,6 +74,13 @@ module Gitlab
def
epics_deepest_relationship_level
{
epics_deepest_relationship_level:
0
}
end
def
topology_usage_data
{
duration_s:
0
,
failures:
[]
}
end
end
end
end
spec/lib/gitlab/usage_data_queries_spec.rb
View file @
c79e8418
...
...
@@ -34,14 +34,14 @@ RSpec.describe Gitlab::UsageDataQueries do
describe
'.redis_usage_data'
do
subject
(
:redis_usage_data
)
{
described_class
.
redis_usage_data
{
42
}
}
it
'returns a class for redis_usage_data with a counter call'
do
it
'returns a
stringified
class for redis_usage_data with a counter call'
do
expect
(
described_class
.
redis_usage_data
(
Gitlab
::
UsageDataCounters
::
WikiPageCounter
))
.
to
eq
(
redis_usage_data_counter:
Gitlab
::
UsageDataCounters
::
WikiPageCounter
)
.
to
eq
(
redis_usage_data_counter:
"Gitlab::UsageDataCounters::WikiPageCounter"
)
end
it
'returns a
stringified block
for redis_usage_data with a block'
do
it
'returns a
placeholder string
for redis_usage_data with a block'
do
is_expected
.
to
include
(
:redis_usage_data_block
)
expect
(
redis_usage_data
[
:redis_usage_data_block
]).
to
start_with
(
'#<Proc:
'
)
expect
(
redis_usage_data
[
:redis_usage_data_block
]).
to
eq
(
'non-SQL usage data block
'
)
end
end
...
...
@@ -53,8 +53,8 @@ RSpec.describe Gitlab::UsageDataQueries do
.
to
eq
(
alt_usage_data_value:
1
)
end
it
'returns a
stringified block
for alt_usage_data with a block'
do
expect
(
alt_usage_data
[
:alt_usage_data_block
]).
to
start_with
(
'#<Proc:
'
)
it
'returns a
placeholder string
for alt_usage_data with a block'
do
expect
(
alt_usage_data
[
:alt_usage_data_block
]).
to
eq
(
'non-SQL usage data block
'
)
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