debian-mirror-gitlab/spec/lib/gitlab/sidekiq_death_handler_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.5 KiB
Ruby
Raw Normal View History

2021-02-22 17:27:13 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::SidekiqDeathHandler, :clean_gitlab_redis_queues do
describe '.handler' do
context 'when the job class has worker attributes' do
let(:test_worker) do
Class.new do
include WorkerAttributes
urgency :low
worker_has_external_dependencies!
worker_resource_boundary :cpu
2023-04-23 21:23:45 +05:30
feature_category :user_profile
2021-02-22 17:27:13 +05:30
end
end
before do
stub_const('TestWorker', test_worker)
end
it 'uses the attributes from the worker' do
expect(described_class.counter)
.to receive(:increment)
2022-07-16 23:28:13 +05:30
.with({ queue: 'test_queue', worker: 'TestWorker',
2022-10-11 01:57:18 +05:30
urgency: 'low', external_dependencies: 'yes',
2023-04-23 21:23:45 +05:30
feature_category: 'user_profile', boundary: 'cpu' })
2021-02-22 17:27:13 +05:30
described_class.handler({ 'class' => 'TestWorker', 'queue' => 'test_queue' }, nil)
end
end
context 'when the job class does not have worker attributes' do
before do
stub_const('TestWorker', Class.new)
end
it 'uses blank attributes' do
expect(described_class.counter)
.to receive(:increment)
2022-07-16 23:28:13 +05:30
.with({ queue: 'test_queue', worker: 'TestWorker',
2022-10-11 01:57:18 +05:30
urgency: '', external_dependencies: 'no',
feature_category: '', boundary: '' })
2021-02-22 17:27:13 +05:30
described_class.handler({ 'class' => 'TestWorker', 'queue' => 'test_queue' }, nil)
end
end
end
end