Skip to content
Snippets Groups Projects

Migrate Sidekiq jobs based on routing rules

Merged Marco (Gregorius) requested to merge pdm-migrate-sidekiq-jobs-to-default into master
All threads resolved!
1 file
+ 31
11
Compare changes
  • Side-by-side
  • Inline
@@ -15,17 +15,37 @@
@@ -15,17 +15,37 @@
EmailReceiverWorker.perform_async('bar')
EmailReceiverWorker.perform_async('bar')
end
end
it 'migrates the jobs to the correct destination queue' do
context 'with worker_queue_mappings mocked' do
allow(Gitlab::SidekiqConfig).to receive(:worker_queue_mappings).and_return({ "EmailReceiverWorker" => "default" })
it 'migrates the jobs to the correct destination queue' do
expect(queue_length('email_receiver')).to eq(2)
allow(Gitlab::SidekiqConfig).to receive(:worker_queue_mappings)
expect(queue_length('default')).to eq(0)
.and_return({ "EmailReceiverWorker" => "default" })
migrate!
expect(queue_length('email_receiver')).to eq(2)
expect(queue_length('email_receiver')).to eq(0)
expect(queue_length('default')).to eq(0)
expect(queue_length('default')).to eq(2)
migrate!
expect(queue_length('email_receiver')).to eq(0)
jobs = list_jobs('default')
expect(queue_length('default')).to eq(2)
expect(jobs[0]).to include("class" => "EmailReceiverWorker", "args" => ["bar"])
expect(jobs[1]).to include("class" => "EmailReceiverWorker", "args" => ["foo"])
jobs = list_jobs('default')
 
expect(jobs[0]).to include("class" => "EmailReceiverWorker", "args" => ["bar"])
 
expect(jobs[1]).to include("class" => "EmailReceiverWorker", "args" => ["foo"])
 
end
 
end
 
 
context 'without worker_queue_mappings mocked' do
 
it 'migration still works' do
 
# Assuming Settings.sidekiq.routing_rules is [['*', 'default']]
 
# If routing_rules or Gitlab::SidekiqConfig.worker_queue_mappings changed,
 
# this spec might be failing. We'll have to adjust the migration or this spec.
 
expect(queue_length('email_receiver')).to eq(2)
 
expect(queue_length('default')).to eq(0)
 
migrate!
 
expect(queue_length('email_receiver')).to eq(0)
 
expect(queue_length('default')).to eq(2)
 
 
jobs = list_jobs('default')
 
expect(jobs[0]).to include("class" => "EmailReceiverWorker", "args" => ["bar"])
 
expect(jobs[1]).to include("class" => "EmailReceiverWorker", "args" => ["foo"])
 
end
end
end
context 'with illegal JSON payload' do
context 'with illegal JSON payload' do
Loading