diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-20 18:19:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-20 18:19:03 +0300 |
commit | 14bd84b61276ef29b97d23642d698de769bacfd2 (patch) | |
tree | f9eba90140c1bd874211dea17750a0d422c04080 /spec/lib/gitlab/usage_data_counters/code_review_events_spec.rb | |
parent | 891c388697b2db0d8ee0c8358a9bdbf6dc56d581 (diff) |
Add latest changes from gitlab-org/gitlab@15-10-stable-eev15.10.0-rc42
Diffstat (limited to 'spec/lib/gitlab/usage_data_counters/code_review_events_spec.rb')
-rw-r--r-- | spec/lib/gitlab/usage_data_counters/code_review_events_spec.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/spec/lib/gitlab/usage_data_counters/code_review_events_spec.rb b/spec/lib/gitlab/usage_data_counters/code_review_events_spec.rb index 63a1da490ed..8da86e4fae5 100644 --- a/spec/lib/gitlab/usage_data_counters/code_review_events_spec.rb +++ b/spec/lib/gitlab/usage_data_counters/code_review_events_spec.rb @@ -6,17 +6,23 @@ require 'spec_helper' # NOTE: ONLY user related metrics to be added to the aggregates - otherwise add it to the exception list RSpec.describe 'Code review events' do it 'the aggregated metrics contain all the code review metrics' do - code_review_events = Gitlab::UsageDataCounters::HLLRedisCounter.events_for_category("code_review") + mr_related_events = %w[i_code_review_create_mr i_code_review_mr_diffs i_code_review_mr_with_invalid_approvers i_code_review_mr_single_file_diffs i_code_review_total_suggestions_applied i_code_review_total_suggestions_added i_code_review_create_note_in_ipynb_diff i_code_review_create_note_in_ipynb_diff_mr i_code_review_create_note_in_ipynb_diff_commit i_code_review_merge_request_widget_license_compliance_warning] + + all_code_review_events = Gitlab::Usage::MetricDefinition.all.flat_map do |definition| + next [] unless definition.attributes[:key_path].include?('.code_review.') && + definition.attributes[:status] == 'active' && + definition.attributes[:instrumentation_class] != 'AggregatedMetric' + + definition.attributes.dig(:options, :events) + end.uniq.compact + code_review_aggregated_events = Gitlab::Usage::MetricDefinition.all.flat_map do |definition| next [] unless code_review_aggregated_metric?(definition.attributes) definition.attributes.dig(:options, :events) end.uniq - exceptions = %w[i_code_review_create_mr i_code_review_mr_diffs i_code_review_mr_with_invalid_approvers i_code_review_mr_single_file_diffs i_code_review_total_suggestions_applied i_code_review_total_suggestions_added i_code_review_create_note_in_ipynb_diff i_code_review_create_note_in_ipynb_diff_mr i_code_review_create_note_in_ipynb_diff_commit] - code_review_aggregated_events += exceptions - - expect(code_review_events - code_review_aggregated_events).to be_empty + expect(all_code_review_events - (code_review_aggregated_events + mr_related_events)).to be_empty end def code_review_aggregated_metric?(attributes) |