Welcome to mirror list, hosted at ThFree Co, Russian Federation.

stuck_import_job_workers_shared_examples.rb « import « gitlab « lib « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 06ea540706a7f76b4ec9a306bdcc3321fd638e37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true

shared_examples 'stuck import job detection' do
  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
          import_state.start
          import_state.finish

          [import_state.jid]
        end
      end

      it 'does not mark the import as failed' do
        worker.perform

        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([import_state.jid])
      end

      it 'marks the import as failed' do
        worker.perform

        expect(import_state.reload.status).to eq('failed')
      end
    end
  end

  context 'when the job is still in Sidekiq' do
    before do
      allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return([])
    end

    it 'does not mark the import as failed' do
      expect { worker.perform }.not_to change { import_state.reload.status }
    end
  end
end