Welcome to mirror list, hosted at ThFree Co, Russian Federation.

instrumentation_logger_spec.rb « sidekiq_middleware « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8cf65e1be5b578250b9ae5667e0962acdac4c4cf (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
51
# 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