diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/initializers | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) | |
download | gitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/initializers')
-rw-r--r-- | spec/initializers/carrierwave_patch_spec.rb | 32 | ||||
-rw-r--r-- | spec/initializers/database_config_spec.rb | 72 | ||||
-rw-r--r-- | spec/initializers/direct_upload_support_spec.rb | 12 |
3 files changed, 72 insertions, 44 deletions
diff --git a/spec/initializers/carrierwave_patch_spec.rb b/spec/initializers/carrierwave_patch_spec.rb new file mode 100644 index 00000000000..d577eca2ac7 --- /dev/null +++ b/spec/initializers/carrierwave_patch_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'CarrierWave::Storage::Fog::File' do + let(:uploader_class) { Class.new(CarrierWave::Uploader::Base) } + let(:uploader) { uploader_class.new } + let(:storage) { CarrierWave::Storage::Fog.new(uploader) } + let(:azure_options) do + { + azure_storage_account_name: 'AZURE_ACCOUNT_NAME', + azure_storage_access_key: 'AZURE_ACCESS_KEY', + provider: 'AzureRM' + } + end + + subject { CarrierWave::Storage::Fog::File.new(uploader, storage, 'test') } + + before do + require 'fog/azurerm' + allow(uploader).to receive(:fog_credentials).and_return(azure_options) + Fog.mock! + end + + describe '#authenticated_url' do + context 'with Azure' do + it 'has an authenticated URL' do + expect(subject.authenticated_url).to eq("https://sa.blob.core.windows.net/test_container/test_blob?token") + end + end + end +end diff --git a/spec/initializers/database_config_spec.rb b/spec/initializers/database_config_spec.rb index 29d499efcd3..ccd69de0b3a 100644 --- a/spec/initializers/database_config_spec.rb +++ b/spec/initializers/database_config_spec.rb @@ -9,65 +9,53 @@ RSpec.describe 'Database config initializer' do before do allow(ActiveRecord::Base).to receive(:establish_connection) + allow(Gitlab::Runtime).to receive(:max_threads).and_return(max_threads) end - context "when using multi-threaded runtime" do - let(:max_threads) { 8 } + let(:max_threads) { 8 } + context "no existing pool size is set" do before do - allow(Gitlab::Runtime).to receive(:multi_threaded?).and_return(true) - allow(Gitlab::Runtime).to receive(:max_threads).and_return(max_threads) + stub_database_config(pool_size: nil) end - context "and no existing pool size is set" do - before do - stub_database_config(pool_size: nil) - end - - it "sets it to the max number of worker threads" do - expect { subject }.to change { Gitlab::Database.config['pool'] }.from(nil).to(max_threads) - end + it "sets it based on the max number of worker threads" do + expect { subject }.to change { Gitlab::Database.config['pool'] }.from(nil).to(18) end + end - context "and the existing pool size is smaller than the max number of worker threads" do - before do - stub_database_config(pool_size: max_threads - 1) - end - - it "sets it to the max number of worker threads" do - expect { subject }.to change { Gitlab::Database.config['pool'] }.by(1) - end + context "the existing pool size is smaller than the max number of worker threads" do + before do + stub_database_config(pool_size: 1) end - context "and the existing pool size is larger than the max number of worker threads" do - before do - stub_database_config(pool_size: max_threads + 1) - end + it "sets it based on the max number of worker threads" do + expect { subject }.to change { Gitlab::Database.config['pool'] }.from(1).to(18) + end + end - it "keeps the configured pool size" do - expect { subject }.not_to change { Gitlab::Database.config['pool'] } - end + context "and the existing pool size is larger than the max number of worker threads" do + before do + stub_database_config(pool_size: 100) end - context "when specifying headroom through an ENV variable" do - let(:headroom) { 10 } + it "sets it based on the max number of worker threads" do + expect { subject }.to change { Gitlab::Database.config['pool'] }.from(100).to(18) + end + end - before do - stub_database_config(pool_size: 1) - stub_env("DB_POOL_HEADROOM", headroom) - end + context "when specifying headroom through an ENV variable" do + let(:headroom) { 15 } - it "adds headroom on top of the calculated size" do - expect { subject }.to change { Gitlab::Database.config['pool'] } - .from(1) - .to(max_threads + headroom) - end + before do + stub_database_config(pool_size: 1) + stub_env("DB_POOL_HEADROOM", headroom) end - end - context "when using single-threaded runtime" do - it "does nothing" do - expect { subject }.not_to change { Gitlab::Database.config['pool'] } + it "adds headroom on top of the calculated size" do + expect { subject }.to change { Gitlab::Database.config['pool'] } + .from(1) + .to(max_threads + headroom) end end diff --git a/spec/initializers/direct_upload_support_spec.rb b/spec/initializers/direct_upload_support_spec.rb index aa77c0905c9..670deecb4f1 100644 --- a/spec/initializers/direct_upload_support_spec.rb +++ b/spec/initializers/direct_upload_support_spec.rb @@ -8,7 +8,7 @@ RSpec.describe 'Direct upload support' do end where(:config_name) do - %w(lfs artifacts uploads) + %w(artifacts lfs uploads) end with_them do @@ -52,11 +52,19 @@ RSpec.describe 'Direct upload support' do end end + context 'when provider is AzureRM' do + let(:provider) { 'AzureRM' } + + it 'succeeds' do + expect { subject }.not_to raise_error + end + end + context 'when connection is empty' do let(:connection) { nil } it 'raises an error' do - expect { subject }.to raise_error "No provider configured for '#{config_name}'. Only Google, AWS are supported." + expect { subject }.to raise_error "No provider configured for '#{config_name}'. Only Google, AWS, and AzureRM are supported." end end |