2020-04-22 19:07:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Gitlab::Import::Metrics do
|
|
|
|
let(:importer) { :test_importer }
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:histogram) { double(:histogram) }
|
|
|
|
let(:counter) { double(:counter) }
|
|
|
|
|
|
|
|
subject { described_class.new(importer, project) }
|
|
|
|
|
|
|
|
describe '#report_import_time' do
|
|
|
|
before do
|
|
|
|
allow(Gitlab::Metrics).to receive(:counter) { counter }
|
|
|
|
allow(Gitlab::Metrics).to receive(:histogram) { histogram }
|
|
|
|
allow(counter).to receive(:increment)
|
|
|
|
allow(counter).to receive(:observe)
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
it 'emits importer metrics' do
|
|
|
|
expect(Gitlab::Metrics).to receive(:counter).with(
|
|
|
|
:test_importer_imported_projects_total,
|
|
|
|
'The number of imported projects'
|
|
|
|
)
|
2020-04-22 19:07:51 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
expect(Gitlab::Metrics).to receive(:histogram).with(
|
|
|
|
:test_importer_total_duration_seconds,
|
|
|
|
'Total time spent importing projects, in seconds',
|
|
|
|
{},
|
|
|
|
described_class::IMPORT_DURATION_BUCKETS
|
|
|
|
)
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
expect(counter).to receive(:increment)
|
2020-07-28 23:09:34 +05:30
|
|
|
expect(histogram).to receive(:observe).with({ importer: :test_importer }, anything)
|
2020-04-22 19:07:51 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
subject.track_finished_import
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|