diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-07 12:09:13 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-07 12:09:13 +0000 |
commit | 211a8c3361ccf4eb92f36edbdcf15c98fcdcc8b7 (patch) | |
tree | 0ad37172721a39b0d57240bb1b4e70f200a0d93e /spec/migrations | |
parent | 456a7247f9e88fc2518b69a1a00e905c6db6d775 (diff) | |
download | gitlab-ce-211a8c3361ccf4eb92f36edbdcf15c98fcdcc8b7.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/fix_projects_without_project_feature_spec.rb | 42 | ||||
-rw-r--r-- | spec/migrations/migrate_propagate_service_template_sidekiq_queue_spec.rb | 29 |
2 files changed, 71 insertions, 0 deletions
diff --git a/spec/migrations/fix_projects_without_project_feature_spec.rb b/spec/migrations/fix_projects_without_project_feature_spec.rb new file mode 100644 index 00000000000..6e0345da078 --- /dev/null +++ b/spec/migrations/fix_projects_without_project_feature_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20200127111840_fix_projects_without_project_feature.rb') + +describe FixProjectsWithoutProjectFeature, :migration do + let(:namespace) { table(:namespaces).create(name: 'gitlab', path: 'gitlab-org') } + + let!(:projects) do + [ + table(:projects).create(namespace_id: namespace.id, name: 'foo 1'), + table(:projects).create(namespace_id: namespace.id, name: 'foo 2'), + table(:projects).create(namespace_id: namespace.id, name: 'foo 3') + ] + end + + before do + stub_const("#{described_class.name}::BATCH_SIZE", 2) + end + + around do |example| + Sidekiq::Testing.fake! do + Timecop.freeze do + example.call + end + end + end + + it 'schedules jobs for ranges of projects' do + migrate! + + expect(described_class::MIGRATION) + .to be_scheduled_delayed_migration(2.minutes, projects[0].id, projects[1].id) + + expect(described_class::MIGRATION) + .to be_scheduled_delayed_migration(4.minutes, projects[2].id, projects[2].id) + end + + it 'schedules jobs according to the configured batch size' do + expect { migrate! }.to change { BackgroundMigrationWorker.jobs.size }.by(2) + end +end diff --git a/spec/migrations/migrate_propagate_service_template_sidekiq_queue_spec.rb b/spec/migrations/migrate_propagate_service_template_sidekiq_queue_spec.rb new file mode 100644 index 00000000000..2fffe638117 --- /dev/null +++ b/spec/migrations/migrate_propagate_service_template_sidekiq_queue_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20200206111847_migrate_propagate_service_template_sidekiq_queue.rb') + +describe MigratePropagateServiceTemplateSidekiqQueue, :sidekiq, :redis do + include Gitlab::Database::MigrationHelpers + include StubWorker + + context 'when there are jobs in the queue' do + it 'correctly migrates queue when migrating up' do + Sidekiq::Testing.disable! do + stub_worker(queue: 'propagate_service_template').perform_async('Something', [1]) + stub_worker(queue: 'propagate_instance_level_service').perform_async('Something', [1]) + + described_class.new.up + + expect(sidekiq_queue_length('propagate_service_template')).to eq 0 + expect(sidekiq_queue_length('propagate_instance_level_service')).to eq 2 + end + end + end + + context 'when there are no jobs in the queues' do + it 'does not raise error when migrating up' do + expect { described_class.new.up }.not_to raise_error + end + end +end |