diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-11-07 14:32:15 +0000 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-11-07 21:24:31 +0000 |
commit | 46b28842b6a05b0b398bdd75e82a00439ad404b0 (patch) | |
tree | dec67df07faa502c02395db11bc4e60bafe05d85 /spec | |
parent | 1183183403cadb465cfec52532cb77ad6a9494c9 (diff) | |
download | gitlab-ce-46b28842b6a05b0b398bdd75e82a00439ad404b0.tar.gz |
StuckImportJobsWorker query performance optimization
Improves the performance of fetching the enqueued
projects for StuckImportJobsWorker, preventing a
statement timeout.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/workers/stuck_import_jobs_worker_spec.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/spec/workers/stuck_import_jobs_worker_spec.rb b/spec/workers/stuck_import_jobs_worker_spec.rb index 2169c14218b..e94d2be9850 100644 --- a/spec/workers/stuck_import_jobs_worker_spec.rb +++ b/spec/workers/stuck_import_jobs_worker_spec.rb @@ -8,29 +8,29 @@ describe StuckImportJobsWorker 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 + import_state.start + import_state.finish - [project.import_jid] + [import_state.jid] end end it 'does not mark the project as failed' do worker.perform - expect(project.reload.import_status).to eq('finished') + expect(import_state.reload.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]) + allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return([import_state.jid]) end it 'marks the project as failed' do worker.perform - expect(project.reload.import_status).to eq('failed') + expect(import_state.reload.status).to eq('failed') end end end @@ -41,27 +41,27 @@ describe StuckImportJobsWorker do end it 'does not mark the project as failed' do - expect { worker.perform }.not_to change { project.reload.import_status } + expect { worker.perform }.not_to change { import_state.reload.status } end end end describe 'with scheduled import_status' do it_behaves_like 'project import job detection' do - let(:project) { create(:project, :import_scheduled) } + let(:import_state) { create(:project, :import_scheduled).import_state } before do - project.import_state.update(jid: '123') + import_state.update(jid: '123') end end end describe 'with started import_status' do it_behaves_like 'project import job detection' do - let(:project) { create(:project, :import_started) } + let(:import_state) { create(:project, :import_started).import_state } before do - project.import_state.update(jid: '123') + import_state.update(jid: '123') end end end |