diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /spec/lib/gitlab/database_spec.rb | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/lib/gitlab/database_spec.rb')
-rw-r--r-- | spec/lib/gitlab/database_spec.rb | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index b735ac7940b..663c8d69328 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -15,9 +15,29 @@ RSpec.describe Gitlab::Database do end end + describe '.default_pool_size' do + before do + allow(Gitlab::Runtime).to receive(:max_threads).and_return(7) + end + + it 'returns the max thread size plus a fixed headroom of 10' do + expect(described_class.default_pool_size).to eq(17) + end + + it 'returns the max thread size plus a DB_POOL_HEADROOM if this env var is present' do + stub_env('DB_POOL_HEADROOM', '7') + + expect(described_class.default_pool_size).to eq(14) + end + end + describe '.config' do - it 'returns a Hash' do - expect(described_class.config).to be_an_instance_of(Hash) + it 'returns a HashWithIndifferentAccess' do + expect(described_class.config).to be_an_instance_of(HashWithIndifferentAccess) + end + + it 'returns a default pool size' do + expect(described_class.config).to include(pool: described_class.default_pool_size) end end @@ -176,7 +196,7 @@ RSpec.describe Gitlab::Database do closed_pool = pool - raise error.new('boom') + raise error, 'boom' end rescue error end @@ -395,13 +415,13 @@ RSpec.describe Gitlab::Database do allow(ActiveRecord::Base.connection).to receive(:execute).and_call_original end - it 'detects a read only database' do + it 'detects a read-only database' do allow(ActiveRecord::Base.connection).to receive(:execute).with('SELECT pg_is_in_recovery()').and_return([{ "pg_is_in_recovery" => "t" }]) expect(described_class.db_read_only?).to be_truthy end - it 'detects a read only database' do + it 'detects a read-only database' do allow(ActiveRecord::Base.connection).to receive(:execute).with('SELECT pg_is_in_recovery()').and_return([{ "pg_is_in_recovery" => true }]) expect(described_class.db_read_only?).to be_truthy |