diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-05 15:11:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-05 15:11:04 +0300 |
commit | 164ac94bbd2eadc02ab54322a6fe12ed48ae8041 (patch) | |
tree | 6eec29a4fd554eeb6f4a1b296e37bdf6fb5f6f80 /spec/workers | |
parent | 8934df30a36d16ac9de9aebb079e16f16fda6912 (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.rb | 3 | ||||
-rw-r--r-- | spec/workers/concerns/gitlab/github_import/rescheduling_methods_spec.rb | 2 | ||||
-rw-r--r-- | spec/workers/concerns/gitlab/import/notify_upon_death_spec.rb (renamed from spec/workers/concerns/gitlab/notify_upon_death_spec.rb) | 10 | ||||
-rw-r--r-- | spec/workers/gitlab/bitbucket_server_import/import_pull_request_worker_spec.rb | 6 | ||||
-rw-r--r-- | spec/workers/gitlab/github_gists_import/import_gist_worker_spec.rb | 8 | ||||
-rw-r--r-- | spec/workers/gitlab/github_import/advance_stage_worker_spec.rb | 11 | ||||
-rw-r--r-- | spec/workers/gitlab/jira_import/import_issue_worker_spec.rb | 2 |
7 files changed, 28 insertions, 14 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 3b7bbfc8a7b..27e1077b138 100644 --- a/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb +++ b/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb @@ -273,7 +273,8 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter, :aggregate_failures, featur .to receive(:notify) .with( job['args'].last, - job['jid'] + job['jid'], + ttl: Gitlab::Import::JOB_WAITER_TTL ) sidekiq_retries_exhausted diff --git a/spec/workers/concerns/gitlab/github_import/rescheduling_methods_spec.rb b/spec/workers/concerns/gitlab/github_import/rescheduling_methods_spec.rb index 6475be0243c..c76ce6b555f 100644 --- a/spec/workers/concerns/gitlab/github_import/rescheduling_methods_spec.rb +++ b/spec/workers/concerns/gitlab/github_import/rescheduling_methods_spec.rb @@ -110,7 +110,7 @@ RSpec.describe Gitlab::GithubImport::ReschedulingMethods, feature_category: :imp expect(Gitlab::JobWaiter) .to receive(:notify) - .with('123', 'abc123') + .with('123', 'abc123', ttl: Gitlab::Import::JOB_WAITER_TTL) worker.notify_waiter('123') end diff --git a/spec/workers/concerns/gitlab/notify_upon_death_spec.rb b/spec/workers/concerns/gitlab/import/notify_upon_death_spec.rb index 36faf3ee296..1f760e8542b 100644 --- a/spec/workers/concerns/gitlab/notify_upon_death_spec.rb +++ b/spec/workers/concerns/gitlab/import/notify_upon_death_spec.rb @@ -2,11 +2,11 @@ require 'spec_helper' -RSpec.describe Gitlab::NotifyUponDeath, feature_category: :shared do +RSpec.describe Gitlab::Import::NotifyUponDeath, feature_category: :importers do let(:worker_class) do Class.new do include Sidekiq::Worker - include Gitlab::NotifyUponDeath + include Gitlab::Import::NotifyUponDeath end end @@ -16,13 +16,13 @@ RSpec.describe Gitlab::NotifyUponDeath, feature_category: :shared do expect(Gitlab::JobWaiter) .to receive(:notify) - .with('123abc', '123') + .with('123abc', '123', ttl: Gitlab::Import::JOB_WAITER_TTL) worker_class.sidekiq_retries_exhausted_block.call(job) end it 'does not notify the JobWaiter when only 2 arguments are given' do - job = { 'args' => [12, {}], 'jid' => '123' } + job = { 'args' => [12, '123abc'], 'jid' => '123' } expect(Gitlab::JobWaiter) .not_to receive(:notify) @@ -31,7 +31,7 @@ RSpec.describe Gitlab::NotifyUponDeath, feature_category: :shared do end it 'does not notify the JobWaiter when only 1 argument is given' do - job = { 'args' => [12], 'jid' => '123' } + job = { 'args' => ['123abc'], 'jid' => '123' } expect(Gitlab::JobWaiter) .not_to receive(:notify) diff --git a/spec/workers/gitlab/bitbucket_server_import/import_pull_request_worker_spec.rb b/spec/workers/gitlab/bitbucket_server_import/import_pull_request_worker_spec.rb index dd3235f846c..376078532cd 100644 --- a/spec/workers/gitlab/bitbucket_server_import/import_pull_request_worker_spec.rb +++ b/spec/workers/gitlab/bitbucket_server_import/import_pull_request_worker_spec.rb @@ -26,7 +26,7 @@ RSpec.describe Gitlab::BitbucketServerImport::ImportPullRequestWorker, feature_c end it 'notifies job waiter' do - expect(Gitlab::JobWaiter).to receive(:notify).with(job_waiter_key, 'jid') + expect(Gitlab::JobWaiter).to receive(:notify).with(job_waiter_key, 'jid', ttl: Gitlab::Import::JOB_WAITER_TTL) worker.perform(project.id, {}, job_waiter_key) end @@ -44,7 +44,7 @@ RSpec.describe Gitlab::BitbucketServerImport::ImportPullRequestWorker, feature_c context 'when project does not exists' do it 'does not call importer and notifies job waiter' do expect(importer_class).not_to receive(:new) - expect(Gitlab::JobWaiter).to receive(:notify).with(job_waiter_key, 'jid') + expect(Gitlab::JobWaiter).to receive(:notify).with(job_waiter_key, 'jid', ttl: Gitlab::Import::JOB_WAITER_TTL) worker.perform(-1, {}, job_waiter_key) end @@ -55,7 +55,7 @@ RSpec.describe Gitlab::BitbucketServerImport::ImportPullRequestWorker, feature_c project = create(:project, :import_canceled) expect(importer_class).not_to receive(:new) - expect(Gitlab::JobWaiter).to receive(:notify).with(job_waiter_key, 'jid') + expect(Gitlab::JobWaiter).to receive(:notify).with(job_waiter_key, 'jid', ttl: Gitlab::Import::JOB_WAITER_TTL) worker.perform(project.id, {}, job_waiter_key) end diff --git a/spec/workers/gitlab/github_gists_import/import_gist_worker_spec.rb b/spec/workers/gitlab/github_gists_import/import_gist_worker_spec.rb index 2e89263bcf3..dc715c3026b 100644 --- a/spec/workers/gitlab/github_gists_import/import_gist_worker_spec.rb +++ b/spec/workers/gitlab/github_gists_import/import_gist_worker_spec.rb @@ -68,7 +68,7 @@ RSpec.describe Gitlab::GithubGistsImport::ImportGistWorker, feature_category: :i .to receive(:info) .with(log_attributes.merge('message' => 'start importer')) expect(importer).to receive(:execute).and_return(importer_result) - expect(Gitlab::JobWaiter).to receive(:notify).with('some_key', subject.jid) + expect(Gitlab::JobWaiter).to receive(:notify).with('some_key', subject.jid, ttl: Gitlab::Import::JOB_WAITER_TTL) expect(Gitlab::GithubImport::Logger) .to receive(:info) .with(log_attributes.merge('message' => 'importer finished')) @@ -114,7 +114,9 @@ RSpec.describe Gitlab::GithubGistsImport::ImportGistWorker, feature_category: :i expect(Gitlab::GithubImport::Logger) .to receive(:error) .with(log_attributes.merge('message' => 'importer failed', 'error.message' => 'error_message')) - expect(Gitlab::JobWaiter).to receive(:notify).with('some_key', subject.jid) + expect(Gitlab::JobWaiter) + .to receive(:notify) + .with('some_key', subject.jid, ttl: Gitlab::Import::JOB_WAITER_TTL) subject.perform(user.id, gist_hash, 'some_key') @@ -189,7 +191,7 @@ RSpec.describe Gitlab::GithubGistsImport::ImportGistWorker, feature_category: :i it 'notifies the JobWaiter' do expect(Gitlab::JobWaiter) .to receive(:notify) - .with(job['args'].last, job['jid']) + .with(job['args'].last, job['jid'], ttl: Gitlab::Import::JOB_WAITER_TTL) sidekiq_retries_exhausted end diff --git a/spec/workers/gitlab/github_import/advance_stage_worker_spec.rb b/spec/workers/gitlab/github_import/advance_stage_worker_spec.rb index 121f30ea9d5..2faa28a365e 100644 --- a/spec/workers/gitlab/github_import/advance_stage_worker_spec.rb +++ b/spec/workers/gitlab/github_import/advance_stage_worker_spec.rb @@ -35,6 +35,17 @@ RSpec.describe Gitlab::GithubImport::AdvanceStageWorker, :clean_gitlab_redis_sha worker.perform(project.id, { '123' => 2 }, :finish) end + + context 'when import state is nil' do + let(:import_state) { nil } + + it 'clears the JobWaiter cache and does not perform any work' do + expect(Gitlab::JobWaiter).to receive(:delete_key).with('123') + expect(worker).not_to receive(:wait_for_jobs) + + worker.perform(project.id, { '123' => 2 }, :finish) + end + end end context 'when there are no remaining jobs' do diff --git a/spec/workers/gitlab/jira_import/import_issue_worker_spec.rb b/spec/workers/gitlab/jira_import/import_issue_worker_spec.rb index 5209395923f..6dfab44b228 100644 --- a/spec/workers/gitlab/jira_import/import_issue_worker_spec.rb +++ b/spec/workers/gitlab/jira_import/import_issue_worker_spec.rb @@ -12,9 +12,9 @@ RSpec.describe Gitlab::JiraImport::ImportIssueWorker, feature_category: :importe describe 'modules' do it { expect(described_class).to include_module(ApplicationWorker) } - it { expect(described_class).to include_module(Gitlab::NotifyUponDeath) } it { expect(described_class).to include_module(Gitlab::JiraImport::QueueOptions) } it { expect(described_class).to include_module(Gitlab::Import::DatabaseHelpers) } + it { expect(described_class).to include_module(Gitlab::Import::NotifyUponDeath) } end subject { described_class.new } |