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

gitaly_apdex_metric_spec.rb « instrumentations « metrics « usage « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fc1e546ef8be3941406d9c2d8ee0f2706fab695f (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Usage::Metrics::Instrumentations::GitalyApdexMetric, feature_category: :service_ping do
  let(:prometheus_client) { instance_double(Gitlab::PrometheusClient) }
  let(:metric) { described_class.new(time_frame: 'none') }

  before do
    allow(prometheus_client).to receive(:query)
      .with(/gitlab_usage_ping:gitaly_apdex:ratio_avg_over_time_5m/)
      .and_return(
        [
          { 'metric' => {},
            'value' => [1616016381.473, '0.95'] }
        ])
    # rubocop:disable RSpec/AnyInstanceOf
    allow_any_instance_of(Gitlab::Utils::UsageData).to receive(:with_prometheus_client).and_yield(prometheus_client)
    # rubocop:enable RSpec/AnyInstanceOf
  end

  it 'gathers gitaly apdex', :aggregate_failures do
    expect(metric.value).to be_within(0.001).of(0.95)
  end
end