diff options
Diffstat (limited to 'spec/lib/container_registry')
-rw-r--r-- | spec/lib/container_registry/client_spec.rb | 53 | ||||
-rw-r--r-- | spec/lib/container_registry/migration_spec.rb | 74 |
2 files changed, 65 insertions, 62 deletions
diff --git a/spec/lib/container_registry/client_spec.rb b/spec/lib/container_registry/client_spec.rb index 39a594eba5c..f9e08df3399 100644 --- a/spec/lib/container_registry/client_spec.rb +++ b/spec/lib/container_registry/client_spec.rb @@ -199,69 +199,16 @@ RSpec.describe ContainerRegistry::Client do let(:redirect_location) { 'http://redirect?foo=bar&test=signature=' } it_behaves_like 'handling redirects' - - context 'with container_registry_follow_redirects_middleware disabled' do - before do - stub_feature_flags(container_registry_follow_redirects_middleware: false) - end - - it 'follows the redirect' do - expect(Faraday::Utils).to receive(:escape).with('foo').and_call_original - expect(Faraday::Utils).to receive(:escape).with('bar').and_call_original - expect(Faraday::Utils).to receive(:escape).with('test').and_call_original - expect(Faraday::Utils).to receive(:escape).with('signature=').and_call_original - - expect_new_faraday(times: 2) - expect(subject).to eq('Successfully redirected') - end - end end context 'with a redirect location with params ending with %3D' do let(:redirect_location) { 'http://redirect?foo=bar&test=signature%3D' } it_behaves_like 'handling redirects' - - context 'with container_registry_follow_redirects_middleware disabled' do - before do - stub_feature_flags(container_registry_follow_redirects_middleware: false) - end - - it 'follows the redirect' do - expect(Faraday::Utils).to receive(:escape).with('foo').and_call_original - expect(Faraday::Utils).to receive(:escape).with('bar').and_call_original - expect(Faraday::Utils).to receive(:escape).with('test').and_call_original - expect(Faraday::Utils).to receive(:escape).with('signature=').and_call_original - - expect_new_faraday(times: 2) - expect(subject).to eq('Successfully redirected') - end - end end end it_behaves_like 'handling timeouts' - - # TODO Remove this context along with the - # container_registry_follow_redirects_middleware feature flag - # See https://gitlab.com/gitlab-org/gitlab/-/issues/353291 - context 'faraday blob' do - subject { client.send(:faraday_blob) } - - it 'has a follow redirects middleware' do - expect(subject.builder.handlers).to include(::FaradayMiddleware::FollowRedirects) - end - - context 'with container_registry_follow_redirects_middleware is disabled' do - before do - stub_feature_flags(container_registry_follow_redirects_middleware: false) - end - - it 'has not a follow redirects middleware' do - expect(subject.builder.handlers).not_to include(::FaradayMiddleware::FollowRedirects) - end - end - end end describe '#upload_blob' do diff --git a/spec/lib/container_registry/migration_spec.rb b/spec/lib/container_registry/migration_spec.rb index 6c0fc94e27f..81dac354b8b 100644 --- a/spec/lib/container_registry/migration_spec.rb +++ b/spec/lib/container_registry/migration_spec.rb @@ -58,21 +58,25 @@ RSpec.describe ContainerRegistry::Migration do describe '.capacity' do subject { described_class.capacity } - where(:ff_1_enabled, :ff_10_enabled, :ff_25_enabled, :expected_result) do - false | false | false | 0 - true | false | false | 1 - true | true | false | 10 - true | true | true | 25 - false | true | false | 10 - false | true | true | 25 - false | false | true | 25 - true | false | true | 25 + where(:ff_1_enabled, :ff_2_enabled, :ff_5_enabled, :ff_10_enabled, :ff_25_enabled, :expected_result) do + false | false | false | false | false | 0 + true | false | false | false | false | 1 + false | true | false | false | false | 2 + true | true | false | false | false | 2 + false | false | true | false | false | 5 + true | true | true | false | false | 5 + false | false | false | true | false | 10 + true | true | true | true | false | 10 + false | false | false | false | true | 25 + true | true | true | true | true | 25 end with_them do before do stub_feature_flags( container_registry_migration_phase2_capacity_1: ff_1_enabled, + container_registry_migration_phase2_capacity_2: ff_2_enabled, + container_registry_migration_phase2_capacity_5: ff_5_enabled, container_registry_migration_phase2_capacity_10: ff_10_enabled, container_registry_migration_phase2_capacity_25: ff_25_enabled ) @@ -154,6 +158,30 @@ RSpec.describe ContainerRegistry::Migration do end end + describe '.pre_import_timeout' do + let(:value) { 10.minutes } + + before do + stub_application_setting(container_registry_pre_import_timeout: value) + end + + it 'returns the matching application_setting' do + expect(described_class.pre_import_timeout).to eq(value) + end + end + + describe '.import_timeout' do + let(:value) { 10.minutes } + + before do + stub_application_setting(container_registry_import_timeout: value) + end + + it 'returns the matching application_setting' do + expect(described_class.import_timeout).to eq(value) + end + end + describe '.target_plans' do subject { described_class.target_plans } @@ -185,4 +213,32 @@ RSpec.describe ContainerRegistry::Migration do it { is_expected.to eq(false) } end end + + describe '.enqueue_twice?' do + subject { described_class.enqueue_twice? } + + it { is_expected.to eq(true) } + + context 'feature flag disabled' do + before do + stub_feature_flags(container_registry_migration_phase2_enqueue_twice: false) + end + + it { is_expected.to eq(false) } + end + end + + describe '.enqueue_loop?' do + subject { described_class.enqueuer_loop? } + + it { is_expected.to eq(true) } + + context 'feature flag disabled' do + before do + stub_feature_flags(container_registry_migration_phase2_enqueuer_loop: false) + end + + it { is_expected.to eq(false) } + end + end end |