debian-mirror-gitlab/spec/migrations/finalize_issues_namespace_id_backfilling_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

77 lines
2.1 KiB
Ruby
Raw Permalink Normal View History

2023-03-04 22:38:38 +05:30
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe FinalizeIssuesNamespaceIdBackfilling, :migration, feature_category: :team_planning do
let(:batched_migrations) { table(:batched_background_migrations) }
let!(:migration) { described_class::MIGRATION }
describe '#up' do
shared_examples 'finalizes the migration' do
it 'finalizes the migration' do
allow_next_instance_of(Gitlab::Database::BackgroundMigration::BatchedMigrationRunner) do |runner|
2023-06-20 00:43:36 +05:30
expect(runner).to receive(:finalize).with(migration, :projects, :id, [])
2023-03-04 22:38:38 +05:30
end
end
end
context 'when routes backfilling migration is missing' do
2023-06-20 00:43:36 +05:30
before do
batched_migrations.where(job_class_name: migration).delete_all
end
2023-03-04 22:38:38 +05:30
it 'warns migration not found' do
expect(Gitlab::AppLogger)
.to receive(:warn).with(/Could not find batched background migration for the given configuration:/)
migrate!
end
end
context 'with backfilling migration present' do
let!(:project_namespace_backfill) do
batched_migrations.create!(
2023-06-20 00:43:36 +05:30
job_class_name: migration,
2023-03-04 22:38:38 +05:30
table_name: :routes,
column_name: :id,
job_arguments: [],
interval: 2.minutes,
min_value: 1,
max_value: 2,
batch_size: 1000,
sub_batch_size: 200,
gitlab_schema: :gitlab_main,
status: 3 # finished
)
end
context 'when backfilling migration finished successfully' do
it 'does not raise exception' do
expect { migrate! }.not_to raise_error
end
end
context 'with different backfilling migration statuses' do
using RSpec::Parameterized::TableSyntax
where(:status, :description) do
0 | 'paused'
1 | 'active'
4 | 'failed'
5 | 'finalizing'
end
with_them do
before do
project_namespace_backfill.update!(status: status)
end
it_behaves_like 'finalizes the migration'
end
end
end
end
end