debian-mirror-gitlab/spec/lib/gitlab/sidekiq_middleware/instrumentation_logger_spec.rb

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

51 lines
1 KiB
Ruby
Raw Normal View History

2021-04-29 21:17:54 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::SidekiqMiddleware::InstrumentationLogger do
let(:job) { { 'jid' => 123 } }
let(:queue) { 'test_queue' }
let(:worker) do
Class.new do
def self.name
'TestDWorker'
end
include ApplicationWorker
2023-03-04 22:38:38 +05:30
def perform(*args); end
2021-04-29 21:17:54 +05:30
end
end
subject { described_class.new }
before do
stub_const('TestWorker', worker)
end
describe '#call', :request_store do
let(:instrumentation_values) do
{
cpu_s: 10,
db_count: 0,
db_cached_count: 0,
db_write_count: 0,
gitaly_calls: 0,
redis_calls: 0
}
end
before do
allow(::Gitlab::InstrumentationHelper).to receive(:add_instrumentation_data) do |values|
values.merge!(instrumentation_values)
end
end
2021-09-04 01:27:46 +05:30
it 'merges all instrumentation data in the job' do
2021-04-29 21:17:54 +05:30
expect { |b| subject.call(worker, job, queue, &b) }.to yield_control
2021-09-04 01:27:46 +05:30
expect(job[:instrumentation]).to eq(instrumentation_values)
2021-04-29 21:17:54 +05:30
end
end
end