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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-19 18:08:39 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-19 18:08:39 +0300
commite1f8f12bbed19bea753d81d7586b30ea403733d5 (patch)
tree379d8f092fa416eb1830c2a8208380e438441b72 /spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
parent235dc61f473cb7f02a9453a59fb26d293e05b092 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/bitbucket_server_import/importer_spec.rb')
-rw-r--r--spec/lib/gitlab/bitbucket_server_import/importer_spec.rb49
1 files changed, 47 insertions, 2 deletions
diff --git a/spec/lib/gitlab/bitbucket_server_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
index cf39d2cb753..570ad916fb2 100644
--- a/spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
+++ b/spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
@@ -5,7 +5,10 @@ require 'spec_helper'
describe Gitlab::BitbucketServerImport::Importer do
include ImportSpecHelper
- let(:project) { create(:project, :repository, import_url: 'http://my-bitbucket') }
+ let(:import_url) { 'http://my-bitbucket' }
+ let(:user) { 'bitbucket' }
+ let(:password) { 'test' }
+ let(:project) { create(:project, :repository, import_url: import_url) }
let(:now) { Time.now.utc.change(usec: 0) }
let(:project_key) { 'TEST' }
let(:repo_slug) { 'rouge' }
@@ -16,7 +19,7 @@ describe Gitlab::BitbucketServerImport::Importer do
before do
data = project.create_or_update_import_data(
data: { project_key: project_key, repo_slug: repo_slug },
- credentials: { base_uri: 'http://my-bitbucket', user: 'bitbucket', password: 'test' }
+ credentials: { base_uri: import_url, user: user, password: password }
)
data.save
project.save
@@ -125,6 +128,48 @@ describe Gitlab::BitbucketServerImport::Importer do
expect(note.updated_at).to eq(@pr_note.created_at)
end
+ context 'metrics' do
+ let(:histogram) { double(:histogram) }
+ let(:counter) { double('counter', increment: true) }
+
+ before do
+ allow(Gitlab::Metrics).to receive(:counter) { counter }
+ allow(Gitlab::Metrics).to receive(:histogram) { histogram }
+ allow(subject.client).to receive(:activities).and_return([@merge_event])
+ end
+
+ it 'counts and measures duration of imported projects' do
+ expect(Gitlab::Metrics).to receive(:counter).with(
+ :bitbucket_server_importer_imported_projects_total,
+ 'The number of imported projects'
+ )
+
+ expect(Gitlab::Metrics).to receive(:histogram).with(
+ :bitbucket_server_importer_total_duration_seconds,
+ 'Total time spent importing projects, in seconds',
+ {},
+ Gitlab::Import::Metrics::IMPORT_DURATION_BUCKETS
+ )
+
+ expect(counter).to receive(:increment)
+ expect(histogram).to receive(:observe).with({ importer: :bitbucket_server_importer }, anything)
+
+ subject.execute
+ end
+
+ it 'counts imported pull requests' do
+ expect(Gitlab::Metrics).to receive(:counter).with(
+ :bitbucket_server_importer_imported_merge_requests_total,
+ 'The number of imported merge (pull) requests'
+ )
+
+ expect(counter).to receive(:increment)
+ allow(histogram).to receive(:observe).with({ importer: :bitbucket_server_importer }, anything)
+
+ subject.execute
+ end
+ end
+
it 'imports threaded discussions' do
reply = instance_double(
BitbucketServer::Representation::PullRequestComment,