diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 18:18:33 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 18:18:33 +0000 |
commit | f64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch) | |
tree | a2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /spec/lib/gitlab/usage_data_counters/aggregated_metrics_spec.rb | |
parent | bfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff) | |
download | gitlab-ce-f64a639bcfa1fc2bc89ca7db268f594306edfd7c.tar.gz |
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'spec/lib/gitlab/usage_data_counters/aggregated_metrics_spec.rb')
-rw-r--r-- | spec/lib/gitlab/usage_data_counters/aggregated_metrics_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/lib/gitlab/usage_data_counters/aggregated_metrics_spec.rb b/spec/lib/gitlab/usage_data_counters/aggregated_metrics_spec.rb index 58f974fbe12..9aba86cdaf2 100644 --- a/spec/lib/gitlab/usage_data_counters/aggregated_metrics_spec.rb +++ b/spec/lib/gitlab/usage_data_counters/aggregated_metrics_spec.rb @@ -23,6 +23,22 @@ RSpec.describe 'aggregated metrics' do end end + RSpec::Matchers.define :have_known_time_frame do + allowed_time_frames = [ + Gitlab::Utils::UsageData::ALL_TIME_TIME_FRAME_NAME, + Gitlab::Utils::UsageData::TWENTY_EIGHT_DAYS_TIME_FRAME_NAME, + Gitlab::Utils::UsageData::SEVEN_DAYS_TIME_FRAME_NAME + ] + + match do |aggregate| + (aggregate[:time_frame] - allowed_time_frames).empty? + end + + failure_message do |aggregate| + "Aggregate with name: `#{aggregate[:name]}` uses not allowed time_frame`#{aggregate[:time_frame] - allowed_time_frames}`" + end + end + let_it_be(:known_events) do Gitlab::UsageDataCounters::HLLRedisCounter.known_events end @@ -38,10 +54,18 @@ RSpec.describe 'aggregated metrics' do expect(aggregated_metrics).to all has_known_source end + it 'all aggregated metrics has known source' do + expect(aggregated_metrics).to all have_known_time_frame + end + aggregated_metrics&.select { |agg| agg[:source] == Gitlab::Usage::Metrics::Aggregates::REDIS_SOURCE }&.each do |aggregate| context "for #{aggregate[:name]} aggregate of #{aggregate[:events].join(' ')}" do let_it_be(:events_records) { known_events.select { |event| aggregate[:events].include?(event[:name]) } } + it "does not include 'all' time frame for Redis sourced aggregate" do + expect(aggregate[:time_frame]).not_to include(Gitlab::Utils::UsageData::ALL_TIME_TIME_FRAME_NAME) + end + it "only refers to known events" do expect(aggregate[:events]).to all be_known_event end |