File: sidekiq_spec.rb

package info (click to toggle)
ruby-gitlab 5.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,660 kB
  • sloc: ruby: 12,582; makefile: 7; sh: 4
file content (66 lines) | stat: -rw-r--r-- 1,940 bytes parent folder | download
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Client do
  describe '.sidekiq_queue_metrics' do
    before do
      stub_get('/sidekiq/queue_metrics', 'sidekiq_queue_metrics')
      @sidekiq_queue_metrics = Gitlab.sidekiq_queue_metrics
    end

    it 'gets the correct resource' do
      expect(a_get('/sidekiq/queue_metrics')).to have_been_made
    end

    it 'returns a information about a sidekiq default queue' do
      expect(@sidekiq_queue_metrics.queues.default.backlog).to eq 0
      expect(@sidekiq_queue_metrics.queues.default.latency).to eq 0
    end
  end

  describe '.sidekiq_process_metrics' do
    before do
      stub_get('/sidekiq/process_metrics', 'sidekiq_process_metrics')
      @sidekiq_process_metrics = Gitlab.sidekiq_process_metrics
    end

    it 'gets the correct resource' do
      expect(a_get('/sidekiq/process_metrics')).to have_been_made
    end

    it 'returns a information about a sidekiq process metrics' do
      expect(@sidekiq_process_metrics.processes.first['busy']).to eq 0
    end
  end

  describe '.sidekiq_job_stats' do
    before do
      stub_get('/sidekiq/job_stats', 'sidekiq_job_stats')
      @sidekiq_job_stats = Gitlab.sidekiq_job_stats
    end

    it 'gets the correct resource' do
      expect(a_get('/sidekiq/job_stats')).to have_been_made
    end

    it 'returns a information about a sidekiq process metrics' do
      expect(@sidekiq_job_stats.jobs.processed).to eq 2
    end
  end

  describe '.sidekiq_compound_metrics' do
    before do
      stub_get('/sidekiq/compound_metrics', 'sidekiq_compound_metrics')
      @sidekiq_compound_metrics = Gitlab.sidekiq_compound_metrics
    end

    it 'gets the correct resource' do
      expect(a_get('/sidekiq/compound_metrics')).to have_been_made
    end

    it 'returns a information about a sidekiq process metrics' do
      expect(@sidekiq_compound_metrics.jobs.processed).to eq 2
    end
  end
end