diff options
author | James Lopez <james@jameslopez.es> | 2017-03-24 14:08:34 +0300 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-04-05 17:11:51 +0300 |
commit | 58371efbb0bd051d3a82f82acac98ad4692efeb4 (patch) | |
tree | 226bfb1a920a6344d6efb3b0357473412aa9dade /spec/workers/stuck_import_jobs_worker_spec.rb | |
parent | 7196adaaa4ce5aa259d285dbca6aa98f4deb046b (diff) |
Periodically mark projects that are stuck in importing as failed
Adds import jid to projects
Refactor middleware to set custom expiration time via sidekiq options
Add completed_jids option to sidekiq status and a few other changes
Diffstat (limited to 'spec/workers/stuck_import_jobs_worker_spec.rb')
-rw-r--r-- | spec/workers/stuck_import_jobs_worker_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/workers/stuck_import_jobs_worker_spec.rb b/spec/workers/stuck_import_jobs_worker_spec.rb new file mode 100644 index 00000000000..466277a5e5e --- /dev/null +++ b/spec/workers/stuck_import_jobs_worker_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +describe StuckImportJobsWorker do + let(:worker) { described_class.new } + let(:exclusive_lease_uuid) { SecureRandom.uuid } + + before do + allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain).and_return(exclusive_lease_uuid) + end + + describe 'long running import' do + let(:project) { create(:empty_project, import_jid: '123', import_status: 'started') } + + before do + allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return(['123']) + end + + it 'marks the project as failed' do + expect { worker.perform }.to change { project.reload.import_status }.to('failed') + end + end + + describe 'running import' do + let(:project) { create(:empty_project, import_jid: '123', import_status: 'started') } + + before do + allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return([]) + end + + it 'does not mark the project as failed' do + worker.perform + + expect(project.reload.import_status).to eq('started') + end + end +end |