diff options
author | Douwe Maan <douwe@selenight.nl> | 2018-02-23 18:25:48 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2018-02-23 18:25:52 +0300 |
commit | 43a359ab78b8282bb541cc14bec02e8a3eece8cb (patch) | |
tree | c2a191717bbbe4a4a154f1c228d19cd1c13d1797 /spec/workers/stuck_import_jobs_worker_spec.rb | |
parent | e610f9604ecd186ae37862894a4f4b7c706d0ce5 (diff) |
Verify project import status again before marking as failed
Diffstat (limited to 'spec/workers/stuck_import_jobs_worker_spec.rb')
-rw-r--r-- | spec/workers/stuck_import_jobs_worker_spec.rb | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/spec/workers/stuck_import_jobs_worker_spec.rb b/spec/workers/stuck_import_jobs_worker_spec.rb index ae24a3f65ac..069514552b1 100644 --- a/spec/workers/stuck_import_jobs_worker_spec.rb +++ b/spec/workers/stuck_import_jobs_worker_spec.rb @@ -2,32 +2,46 @@ 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 shared_examples 'project import job detection' do - describe 'long running import' do - it 'marks the project as failed' do - allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return(['123']) + context 'when the job has completed' do + context 'when the import status was already updated' do + before do + allow(Gitlab::SidekiqStatus).to receive(:completed_jids) do + project.import_start + project.import_finish + + [project.import_jid] + end + end - expect { worker.perform }.to change { project.reload.import_status }.to('failed') + it 'does not mark the project as failed' do + worker.perform + + expect(project.reload.import_status).to eq('finished') + end + end + + context 'when the import status was not updated' do + before do + allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return([project.import_jid]) + end + + it 'marks the project as failed' do + worker.perform + + expect(project.reload.import_status).to eq('failed') + end end end - describe 'running import' do - it 'does not mark the project as failed' do + context 'when the job is still in Sidekiq' do + before do allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return([]) - - expect { worker.perform }.not_to change { project.reload.import_status } end - describe 'import without import_jid' do - it 'marks the project as failed' do - expect { worker.perform }.to change { project.reload.import_status }.to('failed') - end + it 'does not mark the project as failed' do + expect { worker.perform }.not_to change { project.reload.import_status } end end end |