summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 09:08:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 09:08:42 +0000
commitb76ae638462ab0f673e5915986070518dd3f9ad3 (patch)
treebdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb
parent434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff)
downloadgitlab-ce-b76ae638462ab0f673e5915986070518dd3f9ad3.tar.gz
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb
index 20f3270526e..7888ade56eb 100644
--- a/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb
+++ b/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb
@@ -21,3 +21,46 @@ RSpec.shared_examples 'marks background migration job records' do
expect(jobs_updated).to eq(1)
end
end
+
+RSpec.shared_examples 'finalized background migration' do
+ it 'processed the scheduled sidekiq queue' do
+ queued = Sidekiq::ScheduledSet
+ .new
+ .select do |scheduled|
+ scheduled.klass == 'BackgroundMigrationWorker' &&
+ scheduled.args.first == job_class_name
+ end
+ expect(queued.size).to eq(0)
+ end
+
+ it 'processed the async sidekiq queue' do
+ queued = Sidekiq::Queue.new('BackgroundMigrationWorker')
+ .select { |scheduled| scheduled.klass == job_class_name }
+ expect(queued.size).to eq(0)
+ end
+
+ include_examples 'removed tracked jobs', 'pending'
+end
+
+RSpec.shared_examples 'finalized tracked background migration' do
+ include_examples 'finalized background migration'
+ include_examples 'removed tracked jobs', 'succeeded'
+end
+
+RSpec.shared_examples 'removed tracked jobs' do |status|
+ it "removes '#{status}' tracked jobs" do
+ jobs = Gitlab::Database::BackgroundMigrationJob
+ .where(status: Gitlab::Database::BackgroundMigrationJob.statuses[status])
+ .for_migration_class(job_class_name)
+ expect(jobs).to be_empty
+ end
+end
+
+RSpec.shared_examples 'retained tracked jobs' do |status|
+ it "retains '#{status}' tracked jobs" do
+ jobs = Gitlab::Database::BackgroundMigrationJob
+ .where(status: Gitlab::Database::BackgroundMigrationJob.statuses[status])
+ .for_migration_class(job_class_name)
+ expect(jobs).to be_present
+ end
+end