debian-mirror-gitlab/spec/migrations/migrate_storage_migrator_sidekiq_queue_spec.rb

44 lines
1.3 KiB
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
2019-03-02 22:35:43 +05:30
require 'spec_helper'
2021-09-04 01:27:46 +05:30
require_migration!
2019-03-02 22:35:43 +05:30
2020-07-28 23:09:34 +05:30
RSpec.describe MigrateStorageMigratorSidekiqQueue, :redis do
2019-03-02 22:35:43 +05:30
include Gitlab::Database::MigrationHelpers
2019-07-07 11:18:12 +05:30
include StubWorker
2019-03-02 22:35:43 +05:30
context 'when there are jobs in the queues' do
it 'correctly migrates queue when migrating up' do
Sidekiq::Testing.disable! do
2019-07-07 11:18:12 +05:30
stub_worker(queue: :storage_migrator).perform_async(1, 5)
2019-03-02 22:35:43 +05:30
described_class.new.up
expect(sidekiq_queue_length('storage_migrator')).to eq 0
expect(sidekiq_queue_length('hashed_storage:hashed_storage_migrator')).to eq 1
end
end
it 'correctly migrates queue when migrating down' do
Sidekiq::Testing.disable! do
2019-07-07 11:18:12 +05:30
stub_worker(queue: :'hashed_storage:hashed_storage_migrator').perform_async(1, 5)
2019-03-02 22:35:43 +05:30
described_class.new.down
expect(sidekiq_queue_length('storage_migrator')).to eq 1
expect(sidekiq_queue_length('hashed_storage:hashed_storage_migrator')).to eq 0
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
it 'does not raise error when migrating down' do
expect { described_class.new.down }.not_to raise_error
end
end
end