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
8da7d8c4
Commit
8da7d8c4
authored
Sep 04, 2020
by
alinamihaila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check original categories in tests
parent
43575f71
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
129 additions
and
129 deletions
+129
-129
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
.../lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
+129
-129
No files found.
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
View file @
8da7d8c4
...
...
@@ -8,6 +8,23 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
let
(
:entity3
)
{
'34rfjuuy-ce56-sa35-ds34-dfer567dfrf2'
}
let
(
:entity4
)
{
'8b9a2671-2abf-4bec-a682-22f6a8f7bf31'
}
around
do
|
example
|
# We need to freeze to a reference time
# because visits are grouped by the week number in the year
# Without freezing the time, the test may behave inconsistently
# depending on which day of the week test is run.
# Monday 6th of June
reference_time
=
Time
.
utc
(
2020
,
6
,
1
)
Timecop
.
freeze
(
reference_time
)
{
example
.
run
}
end
describe
'.categories'
do
it
'gets all unique category names'
do
expect
(
described_class
.
categories
).
to
contain_exactly
(
'analytics'
,
'compliance'
,
'ide_edit'
,
'search'
)
end
end
describe
'known_events'
do
let
(
:weekly_event
)
{
'g_analytics_contribution'
}
let
(
:daily_event
)
{
'g_analytics_search'
}
let
(
:analytics_slot_event
)
{
'g_analytics_contribution'
}
...
...
@@ -38,28 +55,12 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
allow
(
described_class
).
to
receive
(
:known_events
).
and_return
(
known_events
)
end
around
do
|
example
|
# We need to freeze to a reference time
# because visits are grouped by the week number in the year
# Without freezing the time, the test may behave inconsistently
# depending on which day of the week test is run.
# Monday 6th of June
reference_time
=
Time
.
utc
(
2020
,
6
,
1
)
Timecop
.
freeze
(
reference_time
)
{
example
.
run
}
end
describe
'.events_for_category'
do
it
'gets the event names for given category'
do
expect
(
described_class
.
events_for_category
(
:analytics
)).
to
contain_exactly
(
weekly_event
,
daily_event
)
end
end
describe
'.categories'
do
it
'gets all unique category names'
do
expect
(
described_class
.
categories
).
to
contain_exactly
(
global_category
,
analytics_category
,
productivity_category
,
compliance_category
)
end
end
describe
'.track_event'
do
it
"raise error if metrics don't have same aggregation"
do
expect
{
described_class
.
track_event
(
entity1
,
different_aggregation
,
Date
.
current
)
}
.
to
raise_error
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
::
UnknownAggregation
)
...
...
@@ -194,10 +195,9 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
it
{
expect
(
described_class
.
unique_events
(
event_names:
no_slot
,
start_date:
7
.
days
.
ago
,
end_date:
Date
.
current
)).
to
eq
(
1
)
}
end
end
end
describe
'unique_events_data'
do
let
(
:categories
)
{
described_class
.
categories
}
let
(
:known_events
)
do
[
{
name:
'event1_slot'
,
redis_slot:
"slot"
,
category:
'category1'
,
aggregation:
"weekly"
},
...
...
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