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-13 18:11:15 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-13 18:11:15 +0300
commit7134e029c59d015ccd10aa3bdad1299862947e19 (patch)
treeb06e2e3a8ccab3e76bc50425a7c4cc9957c39975 /spec/workers/gitlab
parentd7ba2e953a7ee4c8ddcd2e5663f369eb5ecbcd72 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/gitlab')
-rw-r--r--spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb9
-rw-r--r--spec/workers/gitlab/import/stuck_import_job_spec.rb36
2 files changed, 43 insertions, 2 deletions
diff --git a/spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb
index bc51a44e057..875fc082975 100644
--- a/spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe Gitlab::GithubImport::Stage::ImportRepositoryWorker do
let(:project) { double(:project, id: 4) }
+
let(:worker) { described_class.new }
describe '#import' do
@@ -36,15 +37,19 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportRepositoryWorker do
context 'when the import fails' do
it 'does not schedule the importing of the base data' do
client = double(:client)
+ exception_class = Gitlab::Git::Repository::NoRepository
expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |instance|
- expect(instance).to receive(:execute).and_return(false)
+ expect(instance).to receive(:execute).and_raise(exception_class)
end
expect(Gitlab::GithubImport::Stage::ImportBaseDataWorker)
.not_to receive(:perform_async)
- worker.import(client, project)
+ expect(worker.abort_on_failure).to eq(true)
+
+ expect { worker.import(client, project) }
+ .to raise_error(exception_class)
end
end
end
diff --git a/spec/workers/gitlab/import/stuck_import_job_spec.rb b/spec/workers/gitlab/import/stuck_import_job_spec.rb
new file mode 100644
index 00000000000..3a1463e98a0
--- /dev/null
+++ b/spec/workers/gitlab/import/stuck_import_job_spec.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::Import::StuckImportJob do
+ let_it_be(:project) { create(:project, :import_started, import_source: 'foo/bar') }
+
+ let(:worker) do
+ Class.new do
+ def self.name
+ 'MyStuckProjectImportsWorker'
+ end
+
+ include(Gitlab::Import::StuckImportJob)
+
+ def track_metrics(...)
+ nil
+ end
+
+ def enqueued_import_states
+ ProjectImportState.with_status([:scheduled, :started])
+ end
+ end.new
+ end
+
+ it 'marks the stuck import project as failed and track the error on import_failures' do
+ worker.perform
+
+ expect(project.import_state.reload.status).to eq('failed')
+ expect(project.import_state.last_error).to eq('Import timed out. Import took longer than 86400 seconds')
+
+ expect(project.import_failures).not_to be_empty
+ expect(project.import_failures.last.exception_class).to eq('Gitlab::Import::StuckImportJob::StuckImportJobError')
+ expect(project.import_failures.last.exception_message).to eq('Import timed out. Import took longer than 86400 seconds')
+ end
+end