diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
commit | 5afcbe03ead9ada87621888a31a62652b10a7e4f (patch) | |
tree | 9918b67a0d0f0bafa6542e839a8be37adf73102d /spec/workers/loose_foreign_keys/cleanup_worker_spec.rb | |
parent | c97c0201564848c1f53226fe19d71fdcc472f7d0 (diff) |
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'spec/workers/loose_foreign_keys/cleanup_worker_spec.rb')
-rw-r--r-- | spec/workers/loose_foreign_keys/cleanup_worker_spec.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/workers/loose_foreign_keys/cleanup_worker_spec.rb b/spec/workers/loose_foreign_keys/cleanup_worker_spec.rb index 2e77f38e221..278efd3406c 100644 --- a/spec/workers/loose_foreign_keys/cleanup_worker_spec.rb +++ b/spec/workers/loose_foreign_keys/cleanup_worker_spec.rb @@ -166,4 +166,66 @@ RSpec.describe LooseForeignKeys::CleanupWorker, feature_category: :cell do end end end + + describe 'turbo mode' do + context 'when turbo mode is off' do + where(:database_name, :feature_flag) do + :main | :loose_foreign_keys_turbo_mode_main + :ci | :loose_foreign_keys_turbo_mode_ci + end + + with_them do + before do + skip unless Gitlab::Database.has_config?(database_name) + stub_feature_flags(feature_flag => false) + end + + it 'does not use TurboModificationTracker' do + allow_next_instance_of(LooseForeignKeys::TurboModificationTracker) do |instance| + expect(instance).not_to receive(:over_limit?) + end + + perform_for(db: database_name) + end + + it 'logs not using turbo mode' do + expect_next_instance_of(LooseForeignKeys::CleanupWorker) do |instance| + expect(instance).to receive(:log_extra_metadata_on_done).with(:stats, a_hash_including(turbo_mode: false)) + end + + perform_for(db: database_name) + end + end + end + + context 'when turbo mode is on' do + where(:database_name, :feature_flag) do + :main | :loose_foreign_keys_turbo_mode_main + :ci | :loose_foreign_keys_turbo_mode_ci + end + + with_them do + before do + skip unless Gitlab::Database.has_config?(database_name) + stub_feature_flags(feature_flag => true) + end + + it 'does not use TurboModificationTracker' do + expect_next_instance_of(LooseForeignKeys::TurboModificationTracker) do |instance| + expect(instance).to receive(:over_limit?).at_least(:once) + end + + perform_for(db: database_name) + end + + it 'logs using turbo mode' do + expect_next_instance_of(LooseForeignKeys::CleanupWorker) do |instance| + expect(instance).to receive(:log_extra_metadata_on_done).with(:stats, a_hash_including(turbo_mode: true)) + end + + perform_for(db: database_name) + end + end + end + end end |