BigW Consortium Gitlab

Commit 24a4199a by Grzegorz Bizon

Reduce a delay between stage_id scheduled migrations

parent 5e2baaf3
...@@ -16,7 +16,7 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration ...@@ -16,7 +16,7 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration
Build.where(stage_id: nil).in_batches(of: BATCH_SIZE) do |relation| Build.where(stage_id: nil).in_batches(of: BATCH_SIZE) do |relation|
jobs = relation.pluck(:id).map { |id| [MIGRATION, [id]] } jobs = relation.pluck(:id).map { |id| [MIGRATION, [id]] }
schedule = index * 5.minutes schedule = index * 2.minutes
index += 1 index += 1
BackgroundMigrationWorker.perform_bulk_in(schedule, jobs) BackgroundMigrationWorker.perform_bulk_in(schedule, jobs)
......
...@@ -47,10 +47,10 @@ describe MigrateStageIdReferenceInBackground, :migration, :sidekiq do ...@@ -47,10 +47,10 @@ describe MigrateStageIdReferenceInBackground, :migration, :sidekiq do
Timecop.freeze do Timecop.freeze do
migrate! migrate!
expect(described_class::MIGRATION).to be_scheduled_migration(5.minutes, 1) expect(described_class::MIGRATION).to be_scheduled_migration(2.minutes, 1)
expect(described_class::MIGRATION).to be_scheduled_migration(5.minutes, 2) expect(described_class::MIGRATION).to be_scheduled_migration(2.minutes, 2)
expect(described_class::MIGRATION).to be_scheduled_migration(10.minutes, 3) expect(described_class::MIGRATION).to be_scheduled_migration(4.minutes, 3)
expect(described_class::MIGRATION).to be_scheduled_migration(10.minutes, 4) expect(described_class::MIGRATION).to be_scheduled_migration(4.minutes, 4)
expect(BackgroundMigrationWorker.jobs.size).to eq 5 expect(BackgroundMigrationWorker.jobs.size).to eq 5
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment