diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/lib/gitlab/sidekiq_queue_spec.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/lib/gitlab/sidekiq_queue_spec.rb')
-rw-r--r-- | spec/lib/gitlab/sidekiq_queue_spec.rb | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/spec/lib/gitlab/sidekiq_queue_spec.rb b/spec/lib/gitlab/sidekiq_queue_spec.rb index 2ab32657f0e..5e91282612e 100644 --- a/spec/lib/gitlab/sidekiq_queue_spec.rb +++ b/spec/lib/gitlab/sidekiq_queue_spec.rb @@ -4,15 +4,15 @@ require 'spec_helper' RSpec.describe Gitlab::SidekiqQueue, :clean_gitlab_redis_queues do around do |example| - Sidekiq::Queue.new('authorized_projects').clear + Sidekiq::Queue.new('default').clear Sidekiq::Testing.disable!(&example) - Sidekiq::Queue.new('authorized_projects').clear + Sidekiq::Queue.new('default').clear end - def add_job(user, args) + def add_job(args, user:, klass: 'AuthorizedProjectsWorker') Sidekiq::Client.push( - 'class' => 'AuthorizedProjectsWorker', - 'queue' => 'authorized_projects', + 'class' => klass, + 'queue' => 'default', 'args' => args, 'meta.user' => user.username ) @@ -20,13 +20,13 @@ RSpec.describe Gitlab::SidekiqQueue, :clean_gitlab_redis_queues do describe '#drop_jobs!' do shared_examples 'queue processing' do - let(:sidekiq_queue) { described_class.new('authorized_projects') } + let(:sidekiq_queue) { described_class.new('default') } let_it_be(:sidekiq_queue_user) { create(:user) } before do - add_job(create(:user), [1]) - add_job(sidekiq_queue_user, [2]) - add_job(sidekiq_queue_user, [3]) + add_job([1], user: create(:user)) + add_job([2], user: sidekiq_queue_user, klass: 'MergeWorker') + add_job([3], user: sidekiq_queue_user) end context 'when the queue is not processed in time' do @@ -68,11 +68,19 @@ RSpec.describe Gitlab::SidekiqQueue, :clean_gitlab_redis_queues do end end + context 'when there are jobs matching the class name' do + include_examples 'queue processing' do + let(:search_metadata) { { user: sidekiq_queue_user.username, worker_class: 'AuthorizedProjectsWorker' } } + let(:timeout_deleted) { 1 } + let(:no_timeout_deleted) { 1 } + end + end + context 'when there are no valid metadata keys passed' do it 'raises NoMetadataError' do - add_job(create(:user), [1]) + add_job([1], user: create(:user)) - expect { described_class.new('authorized_projects').drop_jobs!({ username: 'sidekiq_queue_user' }, timeout: 1) } + expect { described_class.new('default').drop_jobs!({ username: 'sidekiq_queue_user' }, timeout: 1) } .to raise_error(described_class::NoMetadataError) end end |