From 08ed6a867b690a04fe7a74c9ba697cf18f6107d7 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 16 Jan 2020 03:08:47 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/initializers/database_config_spec.rb | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'spec/initializers') diff --git a/spec/initializers/database_config_spec.rb b/spec/initializers/database_config_spec.rb index 9200a625b38..85577ce007a 100644 --- a/spec/initializers/database_config_spec.rb +++ b/spec/initializers/database_config_spec.rb @@ -11,14 +11,12 @@ describe 'Database config initializer' do allow(ActiveRecord::Base).to receive(:establish_connection) end - context "when using Puma" do - let(:puma) { double('puma') } - let(:puma_options) { { max_threads: 8 } } + context "when using multi-threaded runtime" do + let(:max_threads) { 8 } before do - allow(Gitlab::Runtime).to receive(:puma?).and_return(true) - stub_const("Puma", puma) - allow(puma).to receive_message_chain(:cli_config, :options).and_return(puma_options) + allow(Gitlab::Runtime).to receive(:multi_threaded?).and_return(true) + allow(Gitlab::Runtime).to receive(:max_threads).and_return(max_threads) end context "and no existing pool size is set" do @@ -27,23 +25,23 @@ describe 'Database config initializer' do end it "sets it to the max number of worker threads" do - expect { subject }.to change { Gitlab::Database.config['pool'] }.from(nil).to(8) + expect { subject }.to change { Gitlab::Database.config['pool'] }.from(nil).to(max_threads) 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: 7) + 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'] }.from(7).to(8) + expect { subject }.to change { Gitlab::Database.config['pool'] }.by(1) end end context "and the existing pool size is larger than the max number of worker threads" do before do - stub_database_config(pool_size: 9) + stub_database_config(pool_size: max_threads + 1) end it "keeps the configured pool size" do @@ -52,11 +50,7 @@ describe 'Database config initializer' do end end - context "when not using Puma" do - before do - stub_database_config(pool_size: 7) - end - + context "when using single-threaded runtime" do it "does nothing" do expect { subject }.not_to change { Gitlab::Database.config['pool'] } end -- cgit v1.2.3