diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/lib/gitlab/import | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/lib/gitlab/import')
-rw-r--r-- | spec/lib/gitlab/import/database_helpers_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/import/merge_request_creator_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/import/merge_request_helpers_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/import/metrics_spec.rb | 70 | ||||
-rw-r--r-- | spec/lib/gitlab/import/set_async_jid_spec.rb | 2 |
5 files changed, 31 insertions, 47 deletions
diff --git a/spec/lib/gitlab/import/database_helpers_spec.rb b/spec/lib/gitlab/import/database_helpers_spec.rb index 3ac34455177..d56e05df5d7 100644 --- a/spec/lib/gitlab/import/database_helpers_spec.rb +++ b/spec/lib/gitlab/import/database_helpers_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Import::DatabaseHelpers do +RSpec.describe Gitlab::Import::DatabaseHelpers do let(:database_helper) do Class.new do include Gitlab::Import::DatabaseHelpers diff --git a/spec/lib/gitlab/import/merge_request_creator_spec.rb b/spec/lib/gitlab/import/merge_request_creator_spec.rb index 48a57f9b251..9aedca40f1b 100644 --- a/spec/lib/gitlab/import/merge_request_creator_spec.rb +++ b/spec/lib/gitlab/import/merge_request_creator_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Import::MergeRequestCreator do +RSpec.describe Gitlab::Import::MergeRequestCreator do let(:project) { create(:project, :repository) } subject { described_class.new(project) } diff --git a/spec/lib/gitlab/import/merge_request_helpers_spec.rb b/spec/lib/gitlab/import/merge_request_helpers_spec.rb index d81251c4a43..f858ab934bb 100644 --- a/spec/lib/gitlab/import/merge_request_helpers_spec.rb +++ b/spec/lib/gitlab/import/merge_request_helpers_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Import::MergeRequestHelpers, type: :helper do +RSpec.describe Gitlab::Import::MergeRequestHelpers, type: :helper do let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user) } diff --git a/spec/lib/gitlab/import/metrics_spec.rb b/spec/lib/gitlab/import/metrics_spec.rb index 0799d19fcef..0a912427014 100644 --- a/spec/lib/gitlab/import/metrics_spec.rb +++ b/spec/lib/gitlab/import/metrics_spec.rb @@ -2,55 +2,39 @@ require 'spec_helper' -describe Gitlab::Import::Metrics do - let(:importer_stub) do - Class.new do - prepend Gitlab::Import::Metrics - - Gitlab::Import::Metrics.measure :execute, metrics: { - importer_counter: { - type: :counter, - description: 'description' - }, - importer_histogram: { - type: :histogram, - labels: { importer: 'importer' }, - description: 'description' - } - } - - def execute - true - end +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) end - end - - subject { importer_stub.new.execute } - describe '#execute' do - let(:counter) { double(:counter) } - let(:histogram) { double(:histogram) } + it 'emits importer metrics' do + expect(Gitlab::Metrics).to receive(:counter).with( + :test_importer_imported_projects_total, + 'The number of imported projects' + ) - it 'increments counter metric' do - expect(Gitlab::Metrics) - .to receive(:counter) - .with(:importer_counter, 'description') - .and_return(counter) + expect(Gitlab::Metrics).to receive(:histogram).with( + :test_importer_total_duration_seconds, + 'Total time spent importing projects, in seconds', + {}, + described_class::IMPORT_DURATION_BUCKETS + ) expect(counter).to receive(:increment) + expect(histogram).to receive(:observe).with({ importer: :test_importer }, anything) - subject - end - - it 'measures method duration and reports histogram metric' do - expect(Gitlab::Metrics) - .to receive(:histogram) - .with(:importer_histogram, 'description') - .and_return(histogram) - - expect(histogram).to receive(:observe).with({ importer: 'importer' }, anything) - - subject + subject.track_finished_import end end end diff --git a/spec/lib/gitlab/import/set_async_jid_spec.rb b/spec/lib/gitlab/import/set_async_jid_spec.rb index d2933cfd371..6931a7a953d 100644 --- a/spec/lib/gitlab/import/set_async_jid_spec.rb +++ b/spec/lib/gitlab/import/set_async_jid_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -describe Gitlab::Import::SetAsyncJid do +RSpec.describe Gitlab::Import::SetAsyncJid do describe '.set_jid', :clean_gitlab_redis_shared_state do let(:project) { create(:project, :import_scheduled) } |