Commit c94160b9 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch '58739-fix-storage-migration' into 'master'

Fix storage migration check for non-empty queues

Closes #58739

See merge request gitlab-org/gitlab-ce!26109
parents 142c39ae 523712d1
...@@ -97,7 +97,7 @@ module Gitlab ...@@ -97,7 +97,7 @@ module Gitlab
def any_non_empty_queue?(*workers) def any_non_empty_queue?(*workers)
workers.any? do |worker| workers.any? do |worker|
worker.jobs.any? !Sidekiq::Queue.new(worker.queue).size.zero?
end end
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::HashedStorage::Migrator, :sidekiq do describe Gitlab::HashedStorage::Migrator, :sidekiq, :redis do
describe '#bulk_schedule_migration' do describe '#bulk_schedule_migration' do
it 'schedules job to HashedStorage::MigratorWorker' do it 'schedules job to HashedStorage::MigratorWorker' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
...@@ -189,7 +189,7 @@ describe Gitlab::HashedStorage::Migrator, :sidekiq do ...@@ -189,7 +189,7 @@ describe Gitlab::HashedStorage::Migrator, :sidekiq do
set(:project) { create(:project, :empty_repo) } set(:project) { create(:project, :empty_repo) }
it 'returns true when there are MigratorWorker jobs scheduled' do it 'returns true when there are MigratorWorker jobs scheduled' do
Sidekiq::Testing.fake! do Sidekiq::Testing.disable! do
::HashedStorage::MigratorWorker.perform_async(1, 5) ::HashedStorage::MigratorWorker.perform_async(1, 5)
expect(subject.migration_pending?).to be_truthy expect(subject.migration_pending?).to be_truthy
...@@ -197,7 +197,7 @@ describe Gitlab::HashedStorage::Migrator, :sidekiq do ...@@ -197,7 +197,7 @@ describe Gitlab::HashedStorage::Migrator, :sidekiq do
end end
it 'returns true when there are ProjectMigrateWorker jobs scheduled' do it 'returns true when there are ProjectMigrateWorker jobs scheduled' do
Sidekiq::Testing.fake! do Sidekiq::Testing.disable! do
::HashedStorage::ProjectMigrateWorker.perform_async(1) ::HashedStorage::ProjectMigrateWorker.perform_async(1)
expect(subject.migration_pending?).to be_truthy expect(subject.migration_pending?).to be_truthy
...@@ -213,7 +213,7 @@ describe Gitlab::HashedStorage::Migrator, :sidekiq do ...@@ -213,7 +213,7 @@ describe Gitlab::HashedStorage::Migrator, :sidekiq do
set(:project) { create(:project, :empty_repo) } set(:project) { create(:project, :empty_repo) }
it 'returns true when there are RollbackerWorker jobs scheduled' do it 'returns true when there are RollbackerWorker jobs scheduled' do
Sidekiq::Testing.fake! do Sidekiq::Testing.disable! do
::HashedStorage::RollbackerWorker.perform_async(1, 5) ::HashedStorage::RollbackerWorker.perform_async(1, 5)
expect(subject.rollback_pending?).to be_truthy expect(subject.rollback_pending?).to be_truthy
...@@ -221,7 +221,7 @@ describe Gitlab::HashedStorage::Migrator, :sidekiq do ...@@ -221,7 +221,7 @@ describe Gitlab::HashedStorage::Migrator, :sidekiq do
end end
it 'returns true when there are jobs scheduled' do it 'returns true when there are jobs scheduled' do
Sidekiq::Testing.fake! do Sidekiq::Testing.disable! do
::HashedStorage::ProjectRollbackWorker.perform_async(1) ::HashedStorage::ProjectRollbackWorker.perform_async(1)
expect(subject.rollback_pending?).to be_truthy expect(subject.rollback_pending?).to be_truthy
......
...@@ -89,9 +89,9 @@ describe 'rake gitlab:storage:*', :sidekiq do ...@@ -89,9 +89,9 @@ describe 'rake gitlab:storage:*', :sidekiq do
describe 'gitlab:storage:migrate_to_hashed' do describe 'gitlab:storage:migrate_to_hashed' do
let(:task) { 'gitlab:storage:migrate_to_hashed' } let(:task) { 'gitlab:storage:migrate_to_hashed' }
context 'with rollback already scheduled' do context 'with rollback already scheduled', :redis do
it 'does nothing' do it 'does nothing' do
Sidekiq::Testing.fake! do Sidekiq::Testing.disable! do
::HashedStorage::RollbackerWorker.perform_async(1, 5) ::HashedStorage::RollbackerWorker.perform_async(1, 5)
expect(Project).not_to receive(:with_unmigrated_storage) expect(Project).not_to receive(:with_unmigrated_storage)
...@@ -146,9 +146,9 @@ describe 'rake gitlab:storage:*', :sidekiq do ...@@ -146,9 +146,9 @@ describe 'rake gitlab:storage:*', :sidekiq do
it_behaves_like 'make sure database is writable' it_behaves_like 'make sure database is writable'
context 'with migration already scheduled' do context 'with migration already scheduled', :redis do
it 'does nothing' do it 'does nothing' do
Sidekiq::Testing.fake! do Sidekiq::Testing.disable! do
::HashedStorage::MigratorWorker.perform_async(1, 5) ::HashedStorage::MigratorWorker.perform_async(1, 5)
expect(Project).not_to receive(:with_unmigrated_storage) expect(Project).not_to receive(:with_unmigrated_storage)
......
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