diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
commit | 0c872e02b2c822e3397515ec324051ff540f0cd5 (patch) | |
tree | ce2fb6ce7030e4dad0f4118d21ab6453e5938cdd /spec/workers/metrics | |
parent | f7e05a6853b12f02911494c4b3fe53d9540d74fc (diff) |
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'spec/workers/metrics')
-rw-r--r-- | spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb | 13 | ||||
-rw-r--r-- | spec/workers/metrics/dashboard/sync_dashboards_worker_spec.rb | 4 |
2 files changed, 9 insertions, 8 deletions
diff --git a/spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb b/spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb index 11343f69d6f..491ea64cff1 100644 --- a/spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb +++ b/spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb @@ -10,23 +10,24 @@ RSpec.describe Metrics::Dashboard::PruneOldAnnotationsWorker do describe '#perform' do it 'removes all annotations older than cut off', :aggregate_failures do - Timecop.freeze(now) do + travel_to(now) do described_class.new.perform expect(Metrics::Dashboard::Annotation.all).to match_array([one_day_old_annotation, two_weeks_old_annotation]) # is idempotent in the scope of 24h expect { described_class.new.perform }.not_to change { Metrics::Dashboard::Annotation.all.to_a } - travel_to(24.hours.from_now) do - described_class.new.perform - expect(Metrics::Dashboard::Annotation.all).to match_array([one_day_old_annotation]) - end + end + + travel_to(now + 24.hours) do + described_class.new.perform + expect(Metrics::Dashboard::Annotation.all).to match_array([one_day_old_annotation]) end end context 'batch to be deleted is bigger than upper limit' do it 'schedules second job to clear remaining records' do - Timecop.freeze(now) do + travel_to(now) do create(:metrics_dashboard_annotation, starting_at: 1.month.ago) stub_const("#{described_class}::DELETE_LIMIT", 1) diff --git a/spec/workers/metrics/dashboard/sync_dashboards_worker_spec.rb b/spec/workers/metrics/dashboard/sync_dashboards_worker_spec.rb index f151780ffd7..4b670a753e7 100644 --- a/spec/workers/metrics/dashboard/sync_dashboards_worker_spec.rb +++ b/spec/workers/metrics/dashboard/sync_dashboards_worker_spec.rb @@ -12,7 +12,7 @@ RSpec.describe Metrics::Dashboard::SyncDashboardsWorker do describe ".perform" do context 'with valid dashboard hash' do it 'imports metrics' do - expect { worker.perform(project.id) }.to change(PrometheusMetric, :count).by(3) + expect { worker.perform(project.id) }.to change { PrometheusMetric.count }.by(3) end it 'is idempotent' do @@ -32,7 +32,7 @@ RSpec.describe Metrics::Dashboard::SyncDashboardsWorker do end it 'does not import metrics' do - expect { worker.perform(project.id) }.not_to change(PrometheusMetric, :count) + expect { worker.perform(project.id) }.not_to change { PrometheusMetric.count } end it 'does not raise an error' do |