Add tests for Redis HLL class
What does this MR do?
Add tests for Redis HLL class
Building testing case
week number | key | value | Notes |
---|---|---|---|
32 | 2020-32-{expand_vulnerabilities} | user_id_1 | user 1 clicks one time in week 32 |
32 | 2020-32-{expand_vulnerabilities} | user_id_1 | user 1 clicks second time in week 32 |
32 | 2020-32-{expand_vulnerabilities} | user_id_2 | user 2 clicks one time in week 32 |
32 | 2020-32-{expand_vulnerabilities} | user_id_3 | user 3 clicks one time in week 32 |
33 | 2020-33-{expand_vulnerabilities} | user_id_3 | user 3 clicks one time in week 33 |
34 | 2020-34-{expand_vulnerabilities} | user_id_3 | user 3 clicks one time in week 34 |
34 | 2020-34-{expand_vulnerabilities} | user_id_2 | user 2 clicks one time in week 34 |
Results
- count of distinct users that performed expand_vulnerabilities actions for weeks 32, 33, 34 is 3
- count of distinct users that performed expand_vulnerabilities actions for weeks 32, 33 is 3
- count of distinct users that performed expand_vulnerabilities actions for weeks 33, 34 is 2
Code that I used for this example is
# Given data for 3 weeks and one metric: metric base key `expand_vulnerabilities`
# Track one metric named `expand_vulnerabilities`
# With 3 users
Gitlab::Redis::HLL.add(key: '2020-32-{expand_vulnerabilities}', value: "user_id_1", expiry: 29.days)
Gitlab::Redis::HLL.add(key: '2020-32-{expand_vulnerabilities}', value: "user_id_1", expiry: 29.days)
Gitlab::Redis::HLL.add(key: '2020-32-{expand_vulnerabilities}', value: "user_id_2", expiry: 29.days)
Gitlab::Redis::HLL.add(key: '2020-32-{expand_vulnerabilities}', value: "user_id_3", expiry: 29.days)
Gitlab::Redis::HLL.add(key: '2020-33-{expand_vulnerabilities}', value: "user_id_3", expiry: 29.days)
Gitlab::Redis::HLL.add(key: '2020-34-{expand_vulnerabilities}', value: "user_id_3", expiry: 29.days)
Gitlab::Redis::HLL.add(key: '2020-34-{expand_vulnerabilities}', value: "user_id_2", expiry: 29.days)
# count of distinct users that performed expand_vulnerabilities actions for weeks 32, 33, 34
Gitlab::Redis::HLL.count(keys: ["2020-32-{expand_vulnerabilities}", '2020-33-{expand_vulnerabilities}', '2020-34-{expand_vulnerabilities}'])
=> 3
count of distinct users that performed expand_vulnerabilities actions for weeks 32, 33
Gitlab::Redis::HLL.count(keys: ["2020-32-{expand_vulnerabilities}", '2020-33-{expand_vulnerabilities}'])
=> 3
# count of distinct users that performed expand_vulnerabilities actions for weeks 33, 34
Gitlab::Redis::HLL.count(keys: ['2020-33-{expand_vulnerabilities}', '2020-34-{expand_vulnerabilities}'])
=> 2
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Closes #235476 (closed)
Edited by Alina Mihaila