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>2021-08-04 21:09:57 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-04 21:09:57 +0300
commitf5a72705e46f835812ffcc51658eecb08fbdf050 (patch)
tree9b322ce9c0454759d5b669be56e603a481791388 /spec/workers
parent23c4d0c3e1ea30be08b597a961fc91773f60309f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/concerns/gitlab/github_import/object_importer_spec.rb111
-rw-r--r--spec/workers/concerns/gitlab/github_import/stage_methods_spec.rb68
-rw-r--r--spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb27
-rw-r--r--spec/workers/merge_request_mergeability_check_worker_spec.rb20
4 files changed, 114 insertions, 112 deletions
diff --git a/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb b/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb
index ce02100ebfc..ddcf922ad68 100644
--- a/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb
+++ b/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb
@@ -60,26 +60,23 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter do
expect(importer_instance)
.to receive(:execute)
- expect_next_instance_of(Gitlab::Import::Logger) do |logger|
- expect(logger)
- .to receive(:info)
- .with(
- github_id: 1,
- message: 'starting importer',
- import_source: :github,
- project_id: 1,
- importer: 'klass_name'
- )
- expect(logger)
- .to receive(:info)
- .with(
- github_id: 1,
- message: 'importer finished',
- import_source: :github,
- project_id: 1,
- importer: 'klass_name'
- )
- end
+ expect(Gitlab::GithubImport::Logger)
+ .to receive(:info)
+ .with(
+ github_id: 1,
+ message: 'starting importer',
+ project_id: 1,
+ importer: 'klass_name'
+ )
+
+ expect(Gitlab::GithubImport::Logger)
+ .to receive(:info)
+ .with(
+ github_id: 1,
+ message: 'importer finished',
+ project_id: 1,
+ importer: 'klass_name'
+ )
worker.import(project, client, { 'number' => 10, 'github_id' => 1 })
@@ -100,31 +97,28 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter do
.to receive(:execute)
.and_raise(exception)
- expect_next_instance_of(Gitlab::Import::Logger) do |logger|
- expect(logger)
- .to receive(:info)
- .with(
- github_id: 1,
- message: 'starting importer',
- import_source: :github,
- project_id: project.id,
- importer: 'klass_name'
- )
- expect(logger)
- .to receive(:error)
- .with(
- github_id: 1,
- message: 'importer failed',
- import_source: :github,
- project_id: project.id,
- importer: 'klass_name',
- 'error.message': 'some error',
- 'github.data': {
- 'github_id' => 1,
- 'number' => 10
- }
- )
- end
+ expect(Gitlab::GithubImport::Logger)
+ .to receive(:info)
+ .with(
+ github_id: 1,
+ message: 'starting importer',
+ project_id: project.id,
+ importer: 'klass_name'
+ )
+
+ expect(Gitlab::GithubImport::Logger)
+ .to receive(:error)
+ .with(
+ github_id: 1,
+ message: 'importer failed',
+ project_id: project.id,
+ importer: 'klass_name',
+ 'error.message': 'some error',
+ 'github.data': {
+ 'github_id' => 1,
+ 'number' => 10
+ }
+ )
expect(Gitlab::ErrorTracking)
.to receive(:track_and_raise_exception)
@@ -143,21 +137,18 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter do
it 'logs error when representation does not have a github_id' do
expect(importer_class).not_to receive(:new)
- expect_next_instance_of(Gitlab::Import::Logger) do |logger|
- expect(logger)
- .to receive(:error)
- .with(
- github_id: nil,
- message: 'importer failed',
- import_source: :github,
- project_id: project.id,
- importer: 'klass_name',
- 'error.message': 'key not found: :github_id',
- 'github.data': {
- 'number' => 10
- }
- )
- end
+ expect(Gitlab::GithubImport::Logger)
+ .to receive(:error)
+ .with(
+ github_id: nil,
+ message: 'importer failed',
+ project_id: project.id,
+ importer: 'klass_name',
+ 'error.message': 'key not found: :github_id',
+ 'github.data': {
+ 'number' => 10
+ }
+ )
expect(Gitlab::ErrorTracking)
.to receive(:track_and_raise_exception)
diff --git a/spec/workers/concerns/gitlab/github_import/stage_methods_spec.rb b/spec/workers/concerns/gitlab/github_import/stage_methods_spec.rb
index 651ea77a71c..c0e2df6f985 100644
--- a/spec/workers/concerns/gitlab/github_import/stage_methods_spec.rb
+++ b/spec/workers/concerns/gitlab/github_import/stage_methods_spec.rb
@@ -36,24 +36,21 @@ RSpec.describe Gitlab::GithubImport::StageMethods do
an_instance_of(Project)
)
- expect_next_instance_of(Gitlab::Import::Logger) do |logger|
- expect(logger)
- .to receive(:info)
- .with(
- message: 'starting stage',
- import_source: :github,
- project_id: project.id,
- import_stage: 'DummyStage'
- )
- expect(logger)
- .to receive(:info)
- .with(
- message: 'stage finished',
- import_source: :github,
- project_id: project.id,
- import_stage: 'DummyStage'
- )
- end
+ expect(Gitlab::GithubImport::Logger)
+ .to receive(:info)
+ .with(
+ message: 'starting stage',
+ project_id: project.id,
+ import_stage: 'DummyStage'
+ )
+
+ expect(Gitlab::GithubImport::Logger)
+ .to receive(:info)
+ .with(
+ message: 'stage finished',
+ project_id: project.id,
+ import_stage: 'DummyStage'
+ )
worker.perform(project.id)
end
@@ -70,25 +67,22 @@ RSpec.describe Gitlab::GithubImport::StageMethods do
.to receive(:try_import)
.and_raise(exception)
- expect_next_instance_of(Gitlab::Import::Logger) do |logger|
- expect(logger)
- .to receive(:info)
- .with(
- message: 'starting stage',
- import_source: :github,
- project_id: project.id,
- import_stage: 'DummyStage'
- )
- expect(logger)
- .to receive(:error)
- .with(
- message: 'stage failed',
- import_source: :github,
- project_id: project.id,
- import_stage: 'DummyStage',
- 'error.message': 'some error'
- )
- end
+ expect(Gitlab::GithubImport::Logger)
+ .to receive(:info)
+ .with(
+ message: 'starting stage',
+ project_id: project.id,
+ import_stage: 'DummyStage'
+ )
+
+ expect(Gitlab::GithubImport::Logger)
+ .to receive(:error)
+ .with(
+ message: 'stage failed',
+ project_id: project.id,
+ import_stage: 'DummyStage',
+ 'error.message': 'some error'
+ )
expect(Gitlab::ErrorTracking)
.to receive(:track_and_raise_exception)
diff --git a/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb b/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb
index 8dea24dc74f..132fe1dc618 100644
--- a/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb
@@ -26,21 +26,18 @@ RSpec.describe Gitlab::GithubImport::Stage::FinishImportWorker do
.to receive(:increment)
.and_call_original
- expect_next_instance_of(Gitlab::Import::Logger) do |logger|
- expect(logger)
- .to receive(:info)
- .with(
- message: 'GitHub project import finished',
- import_stage: 'Gitlab::GithubImport::Stage::FinishImportWorker',
- import_source: :github,
- object_counts: {
- 'fetched' => {},
- 'imported' => {}
- },
- project_id: project.id,
- duration_s: a_kind_of(Numeric)
- )
- end
+ expect(Gitlab::GithubImport::Logger)
+ .to receive(:info)
+ .with(
+ message: 'GitHub project import finished',
+ import_stage: 'Gitlab::GithubImport::Stage::FinishImportWorker',
+ object_counts: {
+ 'fetched' => {},
+ 'imported' => {}
+ },
+ project_id: project.id,
+ duration_s: a_kind_of(Numeric)
+ )
worker.report_import_time(project)
end
diff --git a/spec/workers/merge_request_mergeability_check_worker_spec.rb b/spec/workers/merge_request_mergeability_check_worker_spec.rb
index 0349de5cbb3..32debcf9651 100644
--- a/spec/workers/merge_request_mergeability_check_worker_spec.rb
+++ b/spec/workers/merge_request_mergeability_check_worker_spec.rb
@@ -10,6 +10,12 @@ RSpec.describe MergeRequestMergeabilityCheckWorker do
it 'does not execute MergeabilityCheckService' do
expect(MergeRequests::MergeabilityCheckService).not_to receive(:new)
+ expect(Sidekiq.logger).to receive(:error).once
+ .with(
+ merge_request_id: 1,
+ worker: "MergeRequestMergeabilityCheckWorker",
+ message: 'Failed to find merge request')
+
subject.perform(1)
end
end
@@ -24,6 +30,20 @@ RSpec.describe MergeRequestMergeabilityCheckWorker do
subject.perform(merge_request.id)
end
+
+ it 'structurally logs a failed mergeability check' do
+ expect_next_instance_of(MergeRequests::MergeabilityCheckService, merge_request) do |service|
+ expect(service).to receive(:execute).and_return(double(error?: true, message: "solar flares"))
+ end
+
+ expect(Sidekiq.logger).to receive(:error).once
+ .with(
+ merge_request_id: merge_request.id,
+ worker: "MergeRequestMergeabilityCheckWorker",
+ message: 'Failed to check mergeability of merge request: solar flares')
+
+ subject.perform(merge_request.id)
+ end
end
it_behaves_like 'an idempotent worker' do