From dbee81480b6a2a88535a0b042012c9fbf287e32b Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 5 Apr 2018 10:53:39 +0200 Subject: Reschedule pipeline stages migration to run it again --- .../reschedule_builds_stages_migration_spec.rb | 35 ++++++++++++++++++++++ .../schedule_build_stage_migration_spec.rb | 35 ---------------------- 2 files changed, 35 insertions(+), 35 deletions(-) create mode 100644 spec/migrations/reschedule_builds_stages_migration_spec.rb delete mode 100644 spec/migrations/schedule_build_stage_migration_spec.rb (limited to 'spec/migrations') diff --git a/spec/migrations/reschedule_builds_stages_migration_spec.rb b/spec/migrations/reschedule_builds_stages_migration_spec.rb new file mode 100644 index 00000000000..ae432f7338f --- /dev/null +++ b/spec/migrations/reschedule_builds_stages_migration_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20180405101928_reschedule_builds_stages_migration') + +describe RescheduleBuildsStagesMigration, :sidekiq, :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 diff --git a/spec/migrations/schedule_build_stage_migration_spec.rb b/spec/migrations/schedule_build_stage_migration_spec.rb deleted file mode 100644 index e2ca35447fb..00000000000 --- a/spec/migrations/schedule_build_stage_migration_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20180212101928_schedule_build_stage_migration') - -describe ScheduleBuildStageMigration, :sidekiq, :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 -- cgit v1.2.1 From 8d012198778fee5b76b777c1a18b60bde62d6f8e Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 5 Apr 2018 12:08:04 +0200 Subject: Update entities in pipeline stages migration test --- spec/migrations/reschedule_builds_stages_migration_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'spec/migrations') diff --git a/spec/migrations/reschedule_builds_stages_migration_spec.rb b/spec/migrations/reschedule_builds_stages_migration_spec.rb index ae432f7338f..3bfd9dd9f6b 100644 --- a/spec/migrations/reschedule_builds_stages_migration_spec.rb +++ b/spec/migrations/reschedule_builds_stages_migration_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20180405101928_reschedule_builds_stages_migration') describe RescheduleBuildsStagesMigration, :sidekiq, :migration do + let(:namespaces) { table(:namespaces) } let(:projects) { table(:projects) } let(:pipelines) { table(:ci_pipelines) } let(:stages) { table(:ci_stages) } @@ -10,7 +11,8 @@ describe RescheduleBuildsStagesMigration, :sidekiq, :migration do before do stub_const("#{described_class}::BATCH_SIZE", 1) - projects.create!(id: 123, name: 'gitlab', path: 'gitlab-ce') + namespaces.create(id: 12, name: 'gitlab-org', path: 'gitlab-org') + projects.create!(id: 123, namespace_id: 12, name: 'gitlab', path: 'gitlab') pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a') stages.create!(id: 1, project_id: 123, pipeline_id: 1, name: 'test') -- cgit v1.2.1