diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-07 06:12:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-07 06:12:02 +0300 |
commit | 71154adca40dc0f8eb80dd1dc81d60ba92af4e99 (patch) | |
tree | 9128c829d09baf5af621218ab2d037fc8d39a2c2 /spec/workers | |
parent | c9a3dc1c2464a92a8f2a5c2f4f30883aa9f976f1 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
4 files changed, 26 insertions, 20 deletions
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 07f35c9e5b7..3f3c5da5b55 100644 --- a/spec/workers/concerns/gitlab/github_import/stage_methods_spec.rb +++ b/spec/workers/concerns/gitlab/github_import/stage_methods_spec.rb @@ -138,6 +138,10 @@ RSpec.describe Gitlab::GithubImport::StageMethods, feature_category: :importers end describe '#try_import' do + before do + allow(worker).to receive(:jid).and_return('jid') + end + it 'imports the project' do client = double(:client) @@ -145,7 +149,7 @@ RSpec.describe Gitlab::GithubImport::StageMethods, feature_category: :importers .to receive(:import) .with(client, project) - expect(project.import_state).to receive(:refresh_jid_expiration) + expect(Gitlab::GithubImport::RefreshImportJidWorker).to receive(:perform_in_the_future).with(project.id, 'jid') worker.try_import(client, project) end @@ -153,7 +157,7 @@ RSpec.describe Gitlab::GithubImport::StageMethods, feature_category: :importers it 'reschedules the worker if RateLimitError was raised' do client = double(:client, rate_limit_resets_in: 10) - expect(project.import_state).to receive(:refresh_jid_expiration) + expect(Gitlab::GithubImport::RefreshImportJidWorker).to receive(:perform_in_the_future).with(project.id, 'jid') expect(worker) .to receive(:import) @@ -186,7 +190,7 @@ RSpec.describe Gitlab::GithubImport::StageMethods, feature_category: :importers end end - describe '.resumes_work_when_interrupted!' do + describe '.sidekiq_options!' do subject(:sidekiq_options) { worker.class.sidekiq_options } it 'does not set the `max_retries_after_interruption` if not called' do @@ -198,5 +202,9 @@ RSpec.describe Gitlab::GithubImport::StageMethods, feature_category: :importers is_expected.to include('max_retries_after_interruption' => 20) end + + it 'sets the status_expiration' do + is_expected.to include('status_expiration' => Gitlab::Import::StuckImportJob::IMPORT_JOBS_EXPIRATION) + end end end diff --git a/spec/workers/gitlab/bitbucket_import/advance_stage_worker_spec.rb b/spec/workers/gitlab/bitbucket_import/advance_stage_worker_spec.rb index 673988a3275..6fcf1ac8822 100644 --- a/spec/workers/gitlab/bitbucket_import/advance_stage_worker_spec.rb +++ b/spec/workers/gitlab/bitbucket_import/advance_stage_worker_spec.rb @@ -53,7 +53,7 @@ RSpec.describe Gitlab::BitbucketImport::AdvanceStageWorker, :clean_gitlab_redis_ it 'schedules the next stage' do expect(import_state) - .to receive(:refresh_jid_expiration) + .to receive(:refresh_jid_expiration).twice expect(Gitlab::BitbucketImport::Stage::FinishImportWorker) .to receive(:perform_async) diff --git a/spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb b/spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb index abba6cd7734..5d0cb05c8d5 100644 --- a/spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb +++ b/spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb @@ -9,7 +9,7 @@ RSpec.describe Gitlab::GithubImport::RefreshImportJidWorker, feature_category: : it 'schedules a job in the future' do expect(described_class) .to receive(:perform_in) - .with(1.minute.to_i, 10, '123') + .with(5.minutes.to_i, 10, '123') described_class.perform_in_the_future(10, '123') end @@ -33,15 +33,20 @@ RSpec.describe Gitlab::GithubImport::RefreshImportJidWorker, feature_category: : allow(worker) .to receive(:find_import_state) .with(project.id) - .and_return(project) + .and_return(import_state) expect(Gitlab::SidekiqStatus) .to receive(:running?) .with('123') .and_return(true) - expect(project) - .to receive(:refresh_jid_expiration) + expect(Gitlab::SidekiqStatus) + .to receive(:expire) + .with('123', Gitlab::Import::StuckImportJob::IMPORT_JOBS_EXPIRATION) + + expect(Gitlab::SidekiqStatus) + .to receive(:set) + .with(import_state.jid, Gitlab::Import::StuckImportJob::IMPORT_JOBS_EXPIRATION) expect(worker.class) .to receive(:perform_in_the_future) @@ -63,8 +68,11 @@ RSpec.describe Gitlab::GithubImport::RefreshImportJidWorker, feature_category: : .with('123') .and_return(false) - expect(project) - .not_to receive(:refresh_jid_expiration) + expect(Gitlab::SidekiqStatus) + .not_to receive(:expire) + + expect(Gitlab::SidekiqStatus) + .not_to receive(:set) worker.perform(project.id, '123') end 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 f4a306eeb0c..020f7539bf4 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 @@ -10,16 +10,6 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportRepositoryWorker, feature_cate it_behaves_like Gitlab::GithubImport::StageMethods describe '#import' do - before do - expect(Gitlab::GithubImport::RefreshImportJidWorker) - .to receive(:perform_in_the_future) - .with(project.id, '123') - - expect(worker) - .to receive(:jid) - .and_return('123') - end - context 'when the import succeeds' do context 'with issues' do it 'schedules the importing of the base data' do |