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

schedule_bulk_repository_shard_moves_shared_examples.rb « services « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 97304680316df7f48fa259d4e4070a9ffc98bdbf (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

RSpec.shared_examples 'moves repository shard in bulk' do
  let(:source_storage_name) { 'default' }
  let(:destination_storage_name) { 'test_second_storage' }

  before do
    stub_storage_settings(destination_storage_name => { 'path' => 'tmp/tests/extra_storage' })
  end

  describe '#execute' do
    it 'schedules container repository storage moves' do
      expect { subject.execute(source_storage_name, destination_storage_name) }
        .to change(move_service_klass, :count).by(1)

      storage_move = container.repository_storage_moves.last!

      expect(storage_move).to have_attributes(
        source_storage_name: source_storage_name,
        destination_storage_name: destination_storage_name,
        state_name: :scheduled
      )
    end

    context 'read-only repository' do
      it 'does not get scheduled' do
        container.set_repository_read_only!

        expect(subject).to receive(:log_info)
          .with(/Container #{container.full_path} \(#{container.id}\) was skipped: #{container.class} is read-only/)
        expect { subject.execute(source_storage_name, destination_storage_name) }
          .to change(move_service_klass, :count).by(0)
      end
    end
  end

  describe '.enqueue' do
    it 'defers to the worker' do
      expect(bulk_worker_klass).to receive(:perform_async).with(source_storage_name, destination_storage_name)

      described_class.enqueue(source_storage_name, destination_storage_name)
    end
  end
end