summaryrefslogtreecommitdiff
path: root/spec/migrations
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-02-27 13:03:30 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2018-02-27 13:03:30 +0000
commit9dac9b7d220a3e1637f00c0af585a654940f6de3 (patch)
tree16563c3e6c6ab2471457d6189a7a3049ac4ece6a /spec/migrations
parent54d0f1bd71cad10b223db2aa2c98756d8ff88e50 (diff)
parentcab8cd7e2ee6ae1b21620443958dd3c312e5c655 (diff)
downloadgitlab-ce-9dac9b7d220a3e1637f00c0af585a654940f6de3.tar.gz
Merge branch 'backstage/gb/build-stages-catch-up-migration' into 'master'
Fully migrate build stages again Closes #38756 See merge request gitlab-org/gitlab-ce!15741
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/schedule_build_stage_migration_spec.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/migrations/schedule_build_stage_migration_spec.rb b/spec/migrations/schedule_build_stage_migration_spec.rb
new file mode 100644
index 00000000000..06657410173
--- /dev/null
+++ b/spec/migrations/schedule_build_stage_migration_spec.rb
@@ -0,0 +1,35 @@
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20180212101928_schedule_build_stage_migration')
+
+describe ScheduleBuildStageMigration, :migration do
+ let(:projects) { table(:projects) }
+ let(:pipelines) { table(:ci_pipelines) }
+ let(:stages) { table(:ci_stages) }
+ let(:jobs) { table(:ci_builds) }
+
+ before do
+ stub_const("#{described_class}::BATCH_SIZE", 1)
+
+ projects.create!(id: 123, name: 'gitlab', path: 'gitlab-ce')
+ pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a')
+ stages.create!(id: 1, project_id: 123, pipeline_id: 1, name: 'test')
+
+ jobs.create!(id: 11, commit_id: 1, project_id: 123, stage_id: nil)
+ jobs.create!(id: 206, commit_id: 1, project_id: 123, stage_id: nil)
+ jobs.create!(id: 3413, commit_id: 1, project_id: 123, stage_id: nil)
+ jobs.create!(id: 4109, commit_id: 1, project_id: 123, stage_id: 1)
+ end
+
+ it 'schedules delayed background migrations in batches in bulk' do
+ Sidekiq::Testing.fake! do
+ Timecop.freeze do
+ migrate!
+
+ expect(described_class::MIGRATION).to be_scheduled_delayed_migration(5.minutes, 11, 11)
+ expect(described_class::MIGRATION).to be_scheduled_delayed_migration(10.minutes, 206, 206)
+ expect(described_class::MIGRATION).to be_scheduled_delayed_migration(15.minutes, 3413, 3413)
+ expect(BackgroundMigrationWorker.jobs.size).to eq 3
+ end
+ end
+ end
+end