summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/bitbucket_import
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-03 03:07:58 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-03 03:07:58 +0000
commit1eeef229aae5affdce415c2364858e8efc64f4b5 (patch)
tree7bbd126a3b41c4c8855a8e84ece3972030177acb /spec/lib/gitlab/bitbucket_import
parent5d32a7a175fd1a7a6c97019a022c11434ea637dc (diff)
downloadgitlab-ce-1eeef229aae5affdce415c2364858e8efc64f4b5.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/bitbucket_import')
-rw-r--r--spec/lib/gitlab/bitbucket_import/importer_spec.rb68
1 files changed, 68 insertions, 0 deletions
diff --git a/spec/lib/gitlab/bitbucket_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_import/importer_spec.rb
index b95175efc0c..b3c1f86c5ee 100644
--- a/spec/lib/gitlab/bitbucket_import/importer_spec.rb
+++ b/spec/lib/gitlab/bitbucket_import/importer_spec.rb
@@ -87,6 +87,7 @@ describe Gitlab::BitbucketImport::Importer do
values: sample_issues_statuses
}
end
+ let(:counter) { double('counter', increment: true) }
subject { described_class.new(project) }
@@ -213,6 +214,24 @@ describe Gitlab::BitbucketImport::Importer do
expect(merge_request_diff.start_commit_sha).to eq target_branch_sha
end
end
+
+ context 'metrics' do
+ before do
+ allow(Gitlab::Metrics).to receive(:counter) { counter }
+ allow(pull_request).to receive(:raw).and_return('hello world')
+ end
+
+ it 'counts imported pull requests' do
+ expect(Gitlab::Metrics).to receive(:counter).with(
+ :bitbucket_importer_imported_pull_requests,
+ 'The number of imported Bitbucket pull requests'
+ )
+
+ expect(counter).to receive(:increment)
+
+ subject.execute
+ end
+ end
end
context 'issues statuses' do
@@ -339,5 +358,54 @@ describe Gitlab::BitbucketImport::Importer do
expect(importer.errors).to be_empty
end
end
+
+ context 'metrics' do
+ before do
+ allow(Gitlab::Metrics).to receive(:counter) { counter }
+ end
+
+ it 'counts imported issues' do
+ expect(Gitlab::Metrics).to receive(:counter).with(
+ :bitbucket_importer_imported_issues,
+ 'The number of imported Bitbucket issues'
+ )
+
+ expect(counter).to receive(:increment)
+
+ subject.execute
+ end
+ end
+ end
+
+ describe '#execute' do
+ context 'metrics' do
+ let(:histogram) { double(:histogram) }
+
+ before do
+ allow(subject).to receive(:import_wiki)
+ allow(subject).to receive(:import_issues)
+ allow(subject).to receive(:import_pull_requests)
+
+ allow(Gitlab::Metrics).to receive(:counter) { counter }
+ allow(Gitlab::Metrics).to receive(:histogram) { histogram }
+ end
+
+ it 'counts and measures duration of imported projects' do
+ expect(Gitlab::Metrics).to receive(:counter).with(
+ :bitbucket_importer_imported_projects,
+ 'The number of imported Bitbucket projects'
+ )
+
+ expect(Gitlab::Metrics).to receive(:histogram).with(
+ :bitbucket_importer_total_duration_seconds,
+ 'Total time spent importing Bitbucket projects, in seconds'
+ )
+
+ expect(counter).to receive(:increment)
+ expect(histogram).to receive(:observe).with({ importer: described_class::IMPORTER }, anything)
+
+ subject.execute
+ end
+ end
end
end