diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-14 12:09:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-14 12:09:21 +0300 |
commit | 1fc72cb8765dab466da8555b70eb744a53a74a80 (patch) | |
tree | c74b37a2056ff89781aee51b2b9ff5c0560a2fb4 /spec/migrations | |
parent | 4fc8a5035217a603a5af54aab09bb7c1bfea7626 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/20230302811133_re_migrate_redis_slot_keys_spec.rb | 8 | ||||
-rw-r--r-- | spec/migrations/20230317004428_migrate_daily_redis_hll_events_to_weekly_aggregation_spec.rb | 19 |
2 files changed, 11 insertions, 16 deletions
diff --git a/spec/migrations/20230302811133_re_migrate_redis_slot_keys_spec.rb b/spec/migrations/20230302811133_re_migrate_redis_slot_keys_spec.rb index d33a80b5e64..b4146761aa2 100644 --- a/spec/migrations/20230302811133_re_migrate_redis_slot_keys_spec.rb +++ b/spec/migrations/20230302811133_re_migrate_redis_slot_keys_spec.rb @@ -10,17 +10,13 @@ RSpec.describe ReMigrateRedisSlotKeys, :migration, feature_category: :service_pi [ { redis_slot: 'management', - aggregation: 'daily', name: 'g_project_management_epic_closed' }, { - aggregation: 'weekly', - name: 'incident_management_incident_assigned' + name: 'incident_management_incident_assigned' # weekly event }, { - aggregation: 'weekly', name: 'non_existing_event' }, { - aggregation: 'weekly', name: 'event_without_expiry' } ] @@ -32,7 +28,7 @@ RSpec.describe ReMigrateRedisSlotKeys, :migration, feature_category: :service_pi .and_return(known_events) expiry_daily = 29.days - expiry_weekly = Gitlab::UsageDataCounters::HLLRedisCounter::DEFAULT_WEEKLY_KEY_EXPIRY_LENGTH + expiry_weekly = described_class::KEY_EXPIRY_LENGTH default_slot = Gitlab::UsageDataCounters::HLLRedisCounter::REDIS_SLOT diff --git a/spec/migrations/20230317004428_migrate_daily_redis_hll_events_to_weekly_aggregation_spec.rb b/spec/migrations/20230317004428_migrate_daily_redis_hll_events_to_weekly_aggregation_spec.rb index 21cdb6afa24..b5bf55f0d86 100644 --- a/spec/migrations/20230317004428_migrate_daily_redis_hll_events_to_weekly_aggregation_spec.rb +++ b/spec/migrations/20230317004428_migrate_daily_redis_hll_events_to_weekly_aggregation_spec.rb @@ -15,29 +15,29 @@ RSpec.describe MigrateDailyRedisHllEventsToWeeklyAggregation, :migration, :clean context 'with daily aggregation' do let(:date_formatted) { date.strftime('%G-%j') } - let(:event) { { aggregation: 'daily', name: 'wiki_action' } } + let(:event) { { name: 'g_edit_by_web_ide' } } it 'returns correct key' do - existing_key = "#{date_formatted}-{hll_counters}_wiki_action" + existing_key = "#{date_formatted}-{hll_counters}_g_edit_by_web_ide" - expect(described_class.new.redis_key(event, date, event[:aggregation])).to eq(existing_key) + expect(described_class.new.redis_key(event, date, :daily)).to eq(existing_key) end end context 'with weekly aggregation' do let(:date_formatted) { date.strftime('%G-%V') } - let(:event) { { aggregation: 'weekly', name: 'weekly_action' } } + let(:event) { { name: 'weekly_action' } } it 'returns correct key' do existing_key = "{hll_counters}_weekly_action-#{date_formatted}" - expect(described_class.new.redis_key(event, date, event[:aggregation])).to eq(existing_key) + expect(described_class.new.redis_key(event, date, :weekly)).to eq(existing_key) end end end context 'with weekly events' do - let(:events) { [{ aggregation: 'weekly', name: 'weekly_action' }] } + let(:events) { [{ name: 'weekly_action' }] } before do allow(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:known_events).and_return(events) @@ -55,13 +55,12 @@ RSpec.describe MigrateDailyRedisHllEventsToWeeklyAggregation, :migration, :clean context 'with daily events' do let(:daily_expiry) { 29.days } - let(:weekly_expiry) { Gitlab::UsageDataCounters::HLLRedisCounter::DEFAULT_WEEKLY_KEY_EXPIRY_LENGTH } + let(:weekly_expiry) { Gitlab::UsageDataCounters::HLLRedisCounter::KEY_EXPIRY_LENGTH } it 'migrates with correct parameters', :aggregate_failures do - events = [{ aggregation: 'daily', name: 'g_project_management_epic_blocked_removed' }] - allow(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:known_events).and_return(events) + event = { name: 'g_project_management_epic_blocked_removed' } + allow(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:known_events).and_return([event]) - event = events.first.dup.tap { |e| e[:aggregation] = 'weekly' } # For every day in the last 30 days, add a value to the daily key with daily expiry (including today) 31.times do |i| key = described_class.new.send(:redis_key, event, Date.today - i.days, :weekly) |