blob: cfb2c7ab5c3df57d6bec5c65e76ebc090709f066 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# 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
def perform(*args); end
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
it 'merges all instrumentation data in the job' do
expect { |b| subject.call(worker, job, queue, &b) }.to yield_control
expect(job[:instrumentation]).to eq(instrumentation_values)
end
end
end
|